summaryrefslogtreecommitdiff
path: root/src/mongo/db/dbmessage.h
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2012-12-19 22:15:03 -0500
committerEliot Horowitz <eliot@10gen.com>2012-12-19 22:19:52 -0500
commitf9817a6cf64bdba8e1e1cef30a798110df746b58 (patch)
tree702cbf8509f2d91e9527a37c4a301c4fe2d74f78 /src/mongo/db/dbmessage.h
parent4be4883faac46fbe45ec65c5ec4e9a93ddaf85e0 (diff)
downloadmongo-f9817a6cf64bdba8e1e1cef30a798110df746b58.tar.gz
SERVER-7769 - turn objcheck on by default and use new fast bson validate
Diffstat (limited to 'src/mongo/db/dbmessage.h')
-rw-r--r--src/mongo/db/dbmessage.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/mongo/db/dbmessage.h b/src/mongo/db/dbmessage.h
index 7b0a802a27f..a582ec1e018 100644
--- a/src/mongo/db/dbmessage.h
+++ b/src/mongo/db/dbmessage.h
@@ -23,6 +23,7 @@
#include "../util/net/message.h"
#include "../client/constants.h"
#include "instance.h"
+#include "mongo/bson/bson_validate.h"
namespace mongo {
@@ -196,14 +197,21 @@ namespace mongo {
nextjsobj += strlen(data) + 1; // skip namespace
massert( 13066 , "Message contains no documents", theEnd > nextjsobj );
}
- massert( 10304 , "Client Error: Remaining data too small for BSON object", theEnd - nextjsobj > 3 );
- BSONObj js(nextjsobj);
- massert( 10305 , "Client Error: Invalid object size", js.objsize() > 3 );
- massert( 10306 , "Client Error: Next object larger than space left in message",
- js.objsize() < ( theEnd - data ) );
- if ( cmdLine.objcheck && !js.valid() ) {
- massert( 10307 , "Client Error: bad object in message", false);
+ massert( 10304,
+ "Client Error: Remaining data too small for BSON object",
+ theEnd - nextjsobj >= 5 );
+
+ if ( cmdLine.objcheck ) {
+ Status status = validateBSON( nextjsobj, theEnd - nextjsobj, NULL );
+ massert( 10307,
+ str::stream() << "Client Error: bad object in message: " << status.reason(),
+ status.isOK() );
}
+
+ BSONObj js(nextjsobj);
+ verify( js.objsize() >= 5 );
+ verify( js.objsize() < ( theEnd - data ) );
+
nextjsobj += js.objsize();
if ( nextjsobj >= theEnd )
nextjsobj = 0;