!23 Delete the unrelated code

Merge pull request !23 from wbq_sky/wbq_0705
This commit is contained in:
openharmony_ci 2021-07-05 04:20:12 +00:00 committed by Gitee
commit cd0f88cc90
2 changed files with 1 additions and 31 deletions

View File

@ -14,9 +14,6 @@
*/
#include "schema_object.h"
#ifndef OMIT_FLATBUFFER
#include <resolv.h>
#endif // OMIT_FLATBUFFER
#include <cmath>
#include <algorithm>
#include "schema_utils.h"
@ -67,28 +64,7 @@ bool SchemaObject::FlatBufferSchema::IsFlatBufferSchema(const std::string &inOri
outDecoded = inOriginal; // The original one is the decoded one
return true;
}
// Try base64 decode. base64 decoded length less then original length.
outDecoded.resize(inOriginal.size());
if (outDecoded.size() != inOriginal.size()) { // Unlikely in normal situation
// Do such check since we will directly access the memory inside outDecoded following
LOGE("[FBSchema][Is] Resize=%zu fail, OOM.", inOriginal.size());
return false;
}
auto decodeBuf = reinterpret_cast<uint8_t *>(outDecoded.data()); // changeable buffer
int decodeLen = b64_pton(inOriginal.c_str(), decodeBuf, outDecoded.size());
LOGD("[FBSchema][Is] Base64 decodeLen=%d, oriLen=%zu.", decodeLen, inOriginal.size());
if (decodeLen <= 0 || decodeLen >= static_cast<int>(inOriginal.size())) {
outDecoded.clear();
return false;
}
// Base64 decode success! It should be an encode form of flatBuffer-Schema.
outDecoded.erase(outDecoded.begin() + decodeLen, outDecoded.end()); // Erase surplus space
auto decodeSchemaBuf = reinterpret_cast<const uint8_t *>(outDecoded.c_str()); // Reget the memory after erase.
flatbuffers::Verifier decodeVerifier(decodeSchemaBuf, outDecoded.size());
if (reflection::VerifySizePrefixedSchemaBuffer(decodeVerifier)) {
return true;
}
LOGE("[FBSchema][Is] Base64 decode success but verify fail.");
outDecoded.clear();
return false;
}

View File

@ -150,12 +150,6 @@ struct SecurityOption {
{
return securityLabel == rhs.securityLabel && securityFlag == rhs.securityFlag;
}
void operator=(const SecurityOption &rhs)
{
securityLabel = rhs.securityLabel;
securityFlag = rhs.securityFlag;
}
};
} // namespace DistributedDB