summaryrefslogtreecommitdiff
path: root/src/mongo/rpc
diff options
context:
space:
mode:
authorAdam Chelminski <adam.chelminski@mongodb.com>2016-08-17 17:11:10 -0400
committerAdam Chelminski <adam.chelminski@mongodb.com>2016-08-19 11:11:23 -0400
commit1a3d60af4d27d72e15637bb43510fe1b592a6c43 (patch)
tree7ab2edd2291f41a2fe37262f32e37618de5f0388 /src/mongo/rpc
parent76f1c8254147f806fef11e9dedabee359422c02b (diff)
downloadmongo-1a3d60af4d27d72e15637bb43510fe1b592a6c43.tar.gz
SERVER-13517 Internal client validates BSON in all command responses and when reading from cursor in DBClientCursor
Diffstat (limited to 'src/mongo/rpc')
-rw-r--r--src/mongo/rpc/legacy_reply.cpp10
-rw-r--r--src/mongo/rpc/legacy_reply.h2
2 files changed, 10 insertions, 2 deletions
diff --git a/src/mongo/rpc/legacy_reply.cpp b/src/mongo/rpc/legacy_reply.cpp
index e9af23dee9e..572a96d2dd2 100644
--- a/src/mongo/rpc/legacy_reply.cpp
+++ b/src/mongo/rpc/legacy_reply.cpp
@@ -33,6 +33,7 @@
#include <tuple>
#include <utility>
+#include "mongo/bson/bson_validate.h"
#include "mongo/rpc/legacy_reply_builder.h"
#include "mongo/rpc/metadata.h"
#include "mongo/util/assert_util.h"
@@ -67,6 +68,15 @@ LegacyReply::LegacyReply(const Message* message) : _message(std::move(message))
<< qr.getStartingFrom(),
qr.getStartingFrom() == 0);
+ if (serverGlobalParams.objcheck) {
+ uassert(ErrorCodes::InvalidBSON,
+ "Got legacy command reply with invalid BSON in the metadata field.",
+ validateBSON(qr.data(),
+ qr.dataLen(),
+ enableBSON1_1 ? BSONVersion::kV1_1 : BSONVersion::kV1_0)
+ .isOK());
+ }
+
std::tie(_commandReply, _metadata) =
uassertStatusOK(rpc::upconvertReplyMetadata(BSONObj(qr.data())));
diff --git a/src/mongo/rpc/legacy_reply.h b/src/mongo/rpc/legacy_reply.h
index bfb366f1da2..7d3d222f59d 100644
--- a/src/mongo/rpc/legacy_reply.h
+++ b/src/mongo/rpc/legacy_reply.h
@@ -41,8 +41,6 @@ namespace rpc {
/**
* Immutable view of an OP_REPLY legacy-style command reply.
- *
- * TODO: BSON validation (SERVER-18167)
*/
class LegacyReply : public ReplyInterface {
public: