summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorWaley Chen <waleycz@gmail.com>2016-03-07 11:30:52 -0500
committerWaley Chen <waleycz@gmail.com>2016-03-07 11:30:52 -0500
commitcfa10de6e60b4eb0fbaa39d8d5e3a3774ad47b95 (patch)
treef266f4ea79b48c01fadfeee4a83c4d3f89269580 /jstests
parenta946a9159660506e0295feaaa6ad5adc0e60f559 (diff)
downloadmongo-cfa10de6e60b4eb0fbaa39d8d5e3a3774ad47b95.tar.gz
SERVER-22767 mongos segfault when invoking .explain() on certain operations
Diffstat (limited to 'jstests')
-rw-r--r--jstests/noPassthrough/server22767.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/jstests/noPassthrough/server22767.js b/jstests/noPassthrough/server22767.js
new file mode 100644
index 00000000000..9b915ce0940
--- /dev/null
+++ b/jstests/noPassthrough/server22767.js
@@ -0,0 +1,21 @@
+// test that the mongos doesn't segfault when it receives malformed BSON
+var st = new ShardingTest({shards:1});
+var testDB = st.getDB('test');
+testDB.test.insert({a:1});
+
+try {
+ testDB.test.find({key: {$regex: 'abcd\0xyz'}}).explain();
+} catch (e) {
+ /*
+ * if the mongos segfaults, the error is the msg:
+ * "Error: error doing query: failed: network error while attempting to run command 'explain' on host '127.0.0.1:20014'"
+ *
+ * if the mongos doesn't segfault, the error is the object:
+ * "Error: explain failed: {
+ * "code" : 22,
+ * "ok" : 0,
+ * "errmsg" : "bson length doesn't match what we found in object with unknown _id"
+ * }"
+ */
+ assert.eq(22, e.code);
+} \ No newline at end of file