summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2020-10-17 03:20:24 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-19 15:05:16 +0000
commit082f1a153bf5245081279e0d1d57048066c493e7 (patch)
treedbe5dbc446a2705901aa5b41894d9fd85c9ea59f /src
parent38e0a213e7f38006656ecce9c782ad318ac537ca (diff)
downloadmongo-082f1a153bf5245081279e0d1d57048066c493e7.tar.gz
SERVER-51719 BSONElement::toString must handle len < 0CLOUDP-69887
Diffstat (limited to 'src')
-rw-r--r--src/mongo/bson/bsonelement.cpp2
-rw-r--r--src/mongo/db/cst/c_node.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/mongo/bson/bsonelement.cpp b/src/mongo/bson/bsonelement.cpp
index 1191f82ecf2..312eb849caf 100644
--- a/src/mongo/bson/bsonelement.cpp
+++ b/src/mongo/bson/bsonelement.cpp
@@ -873,7 +873,7 @@ void BSONElement::toString(
if (!full && len > 80) {
s << hexblob::encode(data, 70) << "...)";
} else {
- s << hexblob::encode(data, len) << ")";
+ s << hexblob::encode(data, std::max(len, 0)) << ")";
}
} break;
diff --git a/src/mongo/db/cst/c_node.cpp b/src/mongo/db/cst/c_node.cpp
index 0c6db03f835..17a89a532fd 100644
--- a/src/mongo/db/cst/c_node.cpp
+++ b/src/mongo/db/cst/c_node.cpp
@@ -120,7 +120,7 @@ auto printValue(const T& payload) {
[](const UserString& userString) { return "<UserString "s + userString + ">"; },
[](const UserBinary& userBinary) {
return "<UserBinary "s + typeName(userBinary.type) + ", " +
- hexblob::encode(userBinary.data, userBinary.length) + ">";
+ hexblob::encode(userBinary.data, std::max(userBinary.length, 0)) + ">";
},
[](const UserUndefined& userUndefined) { return "<UserUndefined>"s; },
[](const UserObjectId& userObjectId) {