|
In src/mongo/bson/bsonelement.h at line 439 in today's master branch, a uassert tests the return value from strnlen() for -1. This function cannot return -1 under any conceivable circumstances, so the test is useless.
// @param maxLen don't scan more than maxLen bytes
|
explicit BSONElement(const char *d, int maxLen) : data(d) {
|
if ( eoo() ) {
|
totalSize = 1;
|
fieldNameSize_ = 0;
|
}
|
else {
|
totalSize = -1;
|
fieldNameSize_ = -1;
|
if ( maxLen != -1 ) {
|
int size = (int) strnlen( fieldName(), maxLen - 1 );
|
uassert( 10333 , "Invalid field name", size != -1 );
|
fieldNameSize_ = size + 1;
|
}
|
}
|
}
|
The only way that strnlen() could return a value that when cast to int would be equal to -1 is if maxLen was zero and the "field name" consisted of 0xFFFFFFFF non-zero characters.
The test should be removed or replaced with something more useful.
|