summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/bson/bson_validate.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/mongo/bson/bson_validate.cpp b/src/mongo/bson/bson_validate.cpp
index a7c95ad1370..cd8819012fc 100644
--- a/src/mongo/bson/bson_validate.cpp
+++ b/src/mongo/bson/bson_validate.cpp
@@ -16,6 +16,7 @@
*/
#include <deque>
+#include <limits>
#include "mongo/bson/bson_validate.h"
#include "mongo/bson/oid.h"
@@ -209,6 +210,8 @@ namespace mongo {
int sz;
if ( !buffer->readNumber<int>( &sz ) )
return Status( ErrorCodes::InvalidBSON, "invalid bson" );
+ if ( sz < 0 || sz == std::numeric_limits<int>::max() )
+ return Status( ErrorCodes::InvalidBSON, "invalid bson" );
if ( !buffer->skip( 1 + sz ) )
return Status( ErrorCodes::InvalidBSON, "invalid bson" );
return Status::OK();