diff options
author | Shreyas Kalyan <shreyaskalyan@gmail.com> | 2018-10-08 15:49:24 -0400 |
---|---|---|
committer | Shreyas Kalyan <shreyaskalyan@gmail.com> | 2018-10-12 16:35:55 -0400 |
commit | 2e58710210f996eea00e192f987ae90acb71abbf (patch) | |
tree | 4eb63e2f39158302eadb96d15013dfde85730e08 /src/mongo/bson | |
parent | 8657f94a66ff4950a9dc4c04eebec86730d87db2 (diff) | |
download | mongo-2e58710210f996eea00e192f987ae90acb71abbf.tar.gz |
SERVER-36272 Catch error in parsing values after % in URIs
Diffstat (limited to 'src/mongo/bson')
-rw-r--r-- | src/mongo/bson/json.cpp | 7 | ||||
-rw-r--r-- | src/mongo/bson/oid.cpp | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/mongo/bson/json.cpp b/src/mongo/bson/json.cpp index f5909e6c3ff..3ad943fdac3 100644 --- a/src/mongo/bson/json.cpp +++ b/src/mongo/bson/json.cpp @@ -400,7 +400,8 @@ Status JParse::binaryObject(StringData fieldName, BSONObjBuilder& builder) { // unsigned char. If we don't coerce it to an unsigned char before // wrapping it in a BinDataType (currently implicitly a signed // integer), we get undefined behavior. - const auto binDataTypeNumeric = static_cast<unsigned char>(fromHex(binDataType)); + const auto binDataTypeNumeric = + static_cast<unsigned char>(uassertStatusOK(fromHex(binDataType))); builder.appendBinData( fieldName, binData.length(), BinDataType(binDataTypeNumeric), binData.data()); @@ -1150,8 +1151,8 @@ Status JParse::chars(std::string* result, const char* terminalSet, const char* a if (!isHexString(StringData(q, 4))) { return parseError("Expecting 4 hex digits"); } - unsigned char first = fromHex(q); - unsigned char second = fromHex(q += 2); + unsigned char first = uassertStatusOK(fromHex(q)); + unsigned char second = uassertStatusOK(fromHex(q += 2)); const std::string& utf8str = encodeUTF8(first, second); for (unsigned int i = 0; i < utf8str.size(); i++) { result->push_back(utf8str[i]); diff --git a/src/mongo/bson/oid.cpp b/src/mongo/bson/oid.cpp index 26d90d97bad..b875cdf10d6 100644 --- a/src/mongo/bson/oid.cpp +++ b/src/mongo/bson/oid.cpp @@ -151,7 +151,7 @@ void OID::init(const std::string& s) { verify(s.size() == 24); const char* p = s.c_str(); for (std::size_t i = 0; i < kOIDSize; i++) { - _data[i] = fromHex(p); + _data[i] = uassertStatusOK(fromHex(p)); p += 2; } } |