summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFox Lady <dandanlin.l@gmail.com>2018-03-20 13:05:50 -0400
committerCharlie Swanson <charlie.swanson@mongodb.com>2018-05-11 18:24:04 -0400
commitf2853bb09946ce5bb7779ff6ad8139a23cf35a90 (patch)
tree609a6620aa37fd1eb407bdb014368a535511865d
parent23533e463e1fabbd9bed8753b013f1028292636d (diff)
downloadmongo-f2853bb09946ce5bb7779ff6ad8139a23cf35a90.tar.gz
SERVER-19904 Avoid massert on field of incorrect type.
Closes #1239 Signed-off-by: Charlie Swanson <charlie.swanson@mongodb.com>
-rw-r--r--src/mongo/db/commands/dbcommands_d.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mongo/db/commands/dbcommands_d.cpp b/src/mongo/db/commands/dbcommands_d.cpp
index a323bd2b3d0..2ad790dedb6 100644
--- a/src/mongo/db/commands/dbcommands_d.cpp
+++ b/src/mongo/db/commands/dbcommands_d.cpp
@@ -195,6 +195,13 @@ public:
// it just passes the buffer through to another mongod.
BSONElement stateElem = jsobj["md5state"];
if (!stateElem.eoo()) {
+ uassert(50847,
+ str::stream() << "The element that calls binDataClean() must be type of "
+ "BinData, but type of "
+ << typeName(stateElem.type())
+ << " found.",
+ (stateElem.type() == BSONType::BinData));
+
int len;
const char* data = stateElem.binDataClean(len);
massert(16247, "md5 state not correct size", len == sizeof(st));
@@ -248,6 +255,18 @@ public:
// make a copy of obj since we access data in it while yielding locks
BSONObj owned = obj.getOwned();
+ uassert(50848,
+ str::stream() << "The element that calls binDataClean() must be type "
+ "of BinData, but type of misisng found. Field name is "
+ "required",
+ owned["data"]);
+ uassert(50849,
+ str::stream() << "The element that calls binDataClean() must be type "
+ "of BinData, but type of "
+ << owned["data"].type()
+ << " found.",
+ owned["data"].type() == BSONType::BinData);
+
exec->saveState();
// UNLOCKED
ctx.reset();