mirror of https://gitee.com/bigwinds/arangodb
replace potentially unsafe binary comparisons with logical ones (#9380)
This commit is contained in:
parent
5eb4951d29
commit
3cedbe4a67
|
@ -1846,14 +1846,14 @@ bool AgencyComm::shouldInitializeStructure() {
|
|||
// Sanity
|
||||
if (result.slice().isArray() && result.slice().length() == 1) {
|
||||
|
||||
// No plan entry? Should initialise
|
||||
if (result.slice()[0] == VPackSlice::emptyObjectSlice()) {
|
||||
// No plan entry? Should initialize
|
||||
if (result.slice()[0].isObject() && result.slice()[0].length() == 0) {
|
||||
LOG_TOPIC(DEBUG, Logger::AGENCYCOMM)
|
||||
<< "agency initialisation should be performed";
|
||||
<< "agency initialization should be performed";
|
||||
return true;
|
||||
} else {
|
||||
LOG_TOPIC(DEBUG, Logger::AGENCYCOMM)
|
||||
<< "agency initialisation under way or done";
|
||||
<< "agency initialization under way or done";
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -431,7 +431,7 @@ JOB_STATUS FailedLeader::status() {
|
|||
auto cur_slice = _snapshot.hasAsSlice(curColPrefix + sub + "/" +
|
||||
clone.shard + "/servers");
|
||||
if (plan_slice.second && cur_slice.second &&
|
||||
plan_slice.first[0] != cur_slice.first[0]) {
|
||||
basics::VelocyPackHelper::compare(plan_slice.first[0], cur_slice.first[0], false) != 0) {
|
||||
LOG_TOPIC(DEBUG, Logger::SUPERVISION)
|
||||
<< "FailedLeader waiting for " << sub + "/" + shard;
|
||||
break;
|
||||
|
|
|
@ -150,12 +150,10 @@ bool Job::finish(std::string const& server, std::string const& shard,
|
|||
|
||||
} // -- operations
|
||||
|
||||
if (preconditions != Slice::emptyObjectSlice()) { // preconditions --
|
||||
if (preconditions.isObject() && preconditions.length() > 0) { // preconditions --
|
||||
VPackObjectBuilder precguard(&finished);
|
||||
if (preconditions.length() > 0) {
|
||||
for (auto const& prec : VPackObjectIterator(preconditions)) {
|
||||
finished.add(prec.key.copyString(), prec.value);
|
||||
}
|
||||
for (auto const& prec : VPackObjectIterator(preconditions)) {
|
||||
finished.add(prec.key.copyString(), prec.value);
|
||||
}
|
||||
} // -- preconditions
|
||||
|
||||
|
@ -490,9 +488,9 @@ std::string Job::findNonblockedCommonHealthyInSyncFollower( // Which is in "GOO
|
|||
bool found = false;
|
||||
for (const auto& plannedServer :
|
||||
VPackArrayIterator(snap.hasAsArray(plannedShardPath).first)) {
|
||||
if (plannedServer == server) {
|
||||
if (plannedServer.isEqualString(server.stringRef())) {
|
||||
found = true;
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -445,9 +445,9 @@ check_ret_t Store::check(VPackSlice const& slice, CheckMode mode) const {
|
|||
if (node->slice().isArray()) {
|
||||
bool _found = false;
|
||||
for (auto const& i : VPackArrayIterator(node->slice())) {
|
||||
if (i == op.value) {
|
||||
if (basics::VelocyPackHelper::compare(i, op.value, false) == 0) {
|
||||
_found = true;
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_found) {
|
||||
|
@ -468,9 +468,9 @@ check_ret_t Store::check(VPackSlice const& slice, CheckMode mode) const {
|
|||
if (node->slice().isArray()) {
|
||||
bool _found = false;
|
||||
for (auto const& i : VPackArrayIterator(node->slice())) {
|
||||
if (i == op.value) {
|
||||
if (basics::VelocyPackHelper::compare(i, op.value, false) == 0) {
|
||||
_found = true;
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_found) {
|
||||
|
|
|
@ -1320,7 +1320,7 @@ void Supervision::readyOrphanedIndexCreations() {
|
|||
currentDBs(colPath + shname + "/indexes").slice();
|
||||
for (auto const& curIndex : VPackArrayIterator(curIndexes)) {
|
||||
auto const& curId = curIndex.get("id");
|
||||
if (planId == curId) {
|
||||
if (basics::VelocyPackHelper::compare(planId, curId, false) == 0) {
|
||||
++nIndexes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6403,7 +6403,8 @@ AqlValue Functions::Append(arangodb::aql::Query* query, transaction::Methods* tr
|
|||
return AqlValue(AqlValueHintNull());
|
||||
}
|
||||
|
||||
std::unordered_set<VPackSlice> added;
|
||||
std::unordered_set<VPackSlice, basics::VelocyPackHelper::VPackHash, basics::VelocyPackHelper::VPackEqual> added(
|
||||
11, basics::VelocyPackHelper::VPackHash(), basics::VelocyPackHelper::VPackEqual());
|
||||
|
||||
transaction::BuilderLeaser builder(trx);
|
||||
builder->openArray();
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "ApplicationFeatures/ApplicationServer.h"
|
||||
#include "Basics/ConditionLocker.h"
|
||||
#include "Basics/MutexLocker.h"
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "Logger/Logger.h"
|
||||
|
||||
using namespace arangodb;
|
||||
|
@ -92,7 +93,7 @@ void AgencyCallback::refetchAndUpdate(bool needToAcquireMutex, bool forceCheck)
|
|||
void AgencyCallback::checkValue(std::shared_ptr<VPackBuilder> newData, bool forceCheck) {
|
||||
// Only called from refetchAndUpdate, we always have the mutex when
|
||||
// we get here!
|
||||
if (!_lastData || !_lastData->slice().equals(newData->slice()) || forceCheck) {
|
||||
if (!_lastData || arangodb::basics::VelocyPackHelper::compare(_lastData->slice(), newData->slice(), false) != 0 || forceCheck) {
|
||||
LOG_TOPIC(DEBUG, Logger::CLUSTER)
|
||||
<< "AgencyCallback: Got new value " << newData->slice().typeName()
|
||||
<< " " << newData->toJson() << " forceCheck=" << forceCheck;
|
||||
|
|
|
@ -3507,7 +3507,7 @@ void ClusterInfo::loadCurrentDBServers() {
|
|||
bool found = false;
|
||||
if (failedDBServers.isObject()) {
|
||||
for (auto const& failedServer : VPackObjectIterator(failedDBServers)) {
|
||||
if (dbserver.key == failedServer.key) {
|
||||
if (basics::VelocyPackHelper::compare(dbserver.key, failedServer.key, false) == 0) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -3520,7 +3520,7 @@ void ClusterInfo::loadCurrentDBServers() {
|
|||
if (cleanedDBServers.isArray()) {
|
||||
bool found = false;
|
||||
for (auto const& cleanedServer : VPackArrayIterator(cleanedDBServers)) {
|
||||
if (dbserver.key == cleanedServer) {
|
||||
if (basics::VelocyPackHelper::compare(dbserver.key, cleanedServer, false) == 0) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -3533,7 +3533,7 @@ void ClusterInfo::loadCurrentDBServers() {
|
|||
if (toBeCleanedDBServers.isArray()) {
|
||||
bool found = false;
|
||||
for (auto const& toBeCleanedServer : VPackArrayIterator(toBeCleanedDBServers)) {
|
||||
if (dbserver.key == toBeCleanedServer) {
|
||||
if (basics::VelocyPackHelper::compare(dbserver.key, toBeCleanedServer, false) == 0) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -304,7 +304,7 @@ static void mergeResultsAllShards(std::vector<std::shared_ptr<VPackBuilder>> con
|
|||
VPackSlice oneRes = it->slice();
|
||||
TRI_ASSERT(oneRes.isArray());
|
||||
oneRes = oneRes.at(currentIndex);
|
||||
if (!oneRes.equals(notFound)) {
|
||||
if (basics::VelocyPackHelper::compare(oneRes, notFound, false) != 0) {
|
||||
// This is the correct result
|
||||
// Use it
|
||||
resultBody->add(oneRes);
|
||||
|
|
|
@ -85,7 +85,7 @@ static std::shared_ptr<VPackBuilder> compareRelevantProps(VPackSlice const& firs
|
|||
VPackObjectBuilder b(result.get());
|
||||
for (auto const& property : cmp) {
|
||||
auto const& planned = first.get(property);
|
||||
if (planned != second.get(property)) { // Register any change
|
||||
if (basics::VelocyPackHelper::compare(planned, second.get(property), false) != 0) { // Register any change
|
||||
result->add(property, planned);
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ void handlePlanShard(VPackSlice const& cprops, VPackSlice const& ldb,
|
|||
}
|
||||
|
||||
// If comparison has brought any updates
|
||||
if (properties->slice() != VPackSlice::emptyObjectSlice() ||
|
||||
if (!properties->slice().isObject() || properties->slice().length() > 0 ||
|
||||
leading != shouldBeLeading || !followersToDropString.empty()) {
|
||||
if (errors.shards.find(fullShardLabel) == errors.shards.end()) {
|
||||
actions.emplace_back(ActionDescription(
|
||||
|
|
|
@ -248,7 +248,7 @@ void runActiveFailoverStart(std::string const& myId) {
|
|||
|
||||
if (leader.isString() && leader.getStringLength() > 0) {
|
||||
ServerState::instance()->setFoxxmaster(leader.copyString());
|
||||
if (leader == myIdBuilder.slice()) {
|
||||
if (basics::VelocyPackHelper::compare(leader, myIdBuilder.slice(), false) == 0) {
|
||||
LOG_TOPIC(INFO, Logger::STARTUP)
|
||||
<< "Became leader in active-failover setup";
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue