summaryrefslogtreecommitdiff
path: root/src/mongo/bson/bson_validate.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2015-02-11 22:12:37 -0500
committerEliot Horowitz <eliot@10gen.com>2015-02-11 22:13:06 -0500
commit394a8569ff14a215c0691aa34440227b2e62a4de (patch)
treebd5de54c3ecbb8182ccd73b73cd0e225b72fadd0 /src/mongo/bson/bson_validate.cpp
parentbc6725d28dd9339dcb3e07e14cfbe868eb4cd563 (diff)
downloadmongo-394a8569ff14a215c0691aa34440227b2e62a4de.tar.gz
SERVER-17264: improve bson validation for utf-8 strings
Diffstat (limited to 'src/mongo/bson/bson_validate.cpp')
-rw-r--r--src/mongo/bson/bson_validate.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mongo/bson/bson_validate.cpp b/src/mongo/bson/bson_validate.cpp
index cd11f4bb77a..5e0a0341909 100644
--- a/src/mongo/bson/bson_validate.cpp
+++ b/src/mongo/bson/bson_validate.cpp
@@ -90,6 +90,11 @@ namespace mongo {
if ( !readNumber<int>( &sz ) )
return makeError("invalid bson", _idElem);
+ if ( sz <= 0 ) {
+ // must have NULL at the very least
+ return makeError("invalid bson", _idElem);
+ }
+
if ( out ) {
*out = StringData( _buffer + _position, sz );
}