diff options
author | Spencer Jackson <spencer.jackson@mongodb.com> | 2016-07-25 14:27:12 -0400 |
---|---|---|
committer | Spencer Jackson <spencer.jackson@mongodb.com> | 2016-07-26 14:22:12 -0400 |
commit | d9ef65edffe7c479c513619462a229fcf0f03c63 (patch) | |
tree | c84fb027d3ae4c2835bd916b7a67a43b511e233d | |
parent | a335a462218be19965da498d91ccc9b23580f84d (diff) | |
download | mongo-d9ef65edffe7c479c513619462a229fcf0f03c63.tar.gz |
SERVER-25258: Improve mongos killOp opID parsing
-rw-r--r-- | jstests/sharding/kill_op_overflow.js | 11 | ||||
-rw-r--r-- | src/mongo/s/commands/cluster_kill_op.cpp | 3 |
2 files changed, 13 insertions, 1 deletions
diff --git a/jstests/sharding/kill_op_overflow.js b/jstests/sharding/kill_op_overflow.js new file mode 100644 index 00000000000..0a4231f5753 --- /dev/null +++ b/jstests/sharding/kill_op_overflow.js @@ -0,0 +1,11 @@ +/** + * This test asserts that an illegal OpID passed to mongos' implementation of killOp results in a + * failure being propagated back to the client. + */ +(function() { + "use strict"; + var st = new ShardingTest({name: "shard1", shards: 1, mongos: 1}); + + assert.commandFailed( + st.s.getDB("admin").runCommand({killOp: 1, op: "shard0000:99999999999999999999999"})); +})(); diff --git a/src/mongo/s/commands/cluster_kill_op.cpp b/src/mongo/s/commands/cluster_kill_op.cpp index b370b31b87d..6e7ab3ab2bb 100644 --- a/src/mongo/s/commands/cluster_kill_op.cpp +++ b/src/mongo/s/commands/cluster_kill_op.cpp @@ -108,7 +108,8 @@ public: str::stream() << "shard " << shardIdent << " does not exist")); } - auto opId = std::stoi(opToKill.substr(opSepPos + 1)); + int opId; + uassertStatusOK(parseNumberFromStringWithBase(opToKill.substr(opSepPos + 1), 10, &opId)); // shardid is actually the opid - keeping for backwards compatibility. result.append("shard", shardIdent); |