8000 Check whether name is empty in getCollectionId{Local,Cluster} before … · arangodb/arangodb@bb8e85f · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit bb8e85f

Browse files
author
Markus Pfeiffer
committed
Check whether name 8000 is empty in getCollectionId{Local,Cluster} before access
1 parent 4029e9d commit bb8e85f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

arangod/Utils/CollectionNameResolver.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,21 @@ std::shared_ptr<LogicalCollection> CollectionNameResolver::getCollection(std::st
7070
//////////////////////////////////////////////////////////////////////////////
7171

7272
TRI_voc_cid_t CollectionNameResolver::getCollectionIdLocal(std::string const& name) const {
73-
if (name[0] >= '0' && name[0] <= '9') {
73+
if (name.empty()) {
74+
return 0;
75+
}
76+
77+
if (isdigit(name[0])) {
7478
// name is a numeric id
7579
return NumberUtils::atoi_zero<TRI_voc_cid_t>(name.data(), name.data() + name.size());
7680
}
7781

7882
auto collection = getCollectionStruct(name);
79-
8083
if (collection != nullptr) {
8184
return collection->id();
8285
}
8386

8487
auto view = _vocbase.lookupView(name);
85-
8688
if (view) {
8789
return view->id();
8890
}
@@ -101,7 +103,10 @@ TRI_voc_cid_t CollectionNameResolver::getCollectionIdCluster(std::string const&
101103
if (!ServerState::isRunningInCluster(_serverRole)) {
1 9B23 02104
return getCollectionIdLocal(name);
103105
}
104-
if (name[0] >= '0' && name[0] <= '9') {
106+
if (name.empty()) {
107+
return 0;
108+
}
109+
if (isdigit(name[0])) {
105110
// name is a numeric id
106111
TRI_voc_cid_t cid =
107112
NumberUtils::atoi_zero<TRI_voc_cid_t>(name.data(), name.data() + name.size());
@@ -135,6 +140,7 @@ TRI_voc_cid_t CollectionNameResolver::getCollectionIdCluster(std::string const&
135140
return vinfo->id();
136141
}
137142
} catch (...) {
143+
// TODO: ?
138144
}
139145

140146
return 0;

0 commit comments

Comments
 (0)
0