Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
None
-
None
Description
The following lines:
const int size = 4+1+len;
if ( ! bson_append_estart( b , bson_bindata , name , size ) ) return 0;
bson_append32(b, &size);
Should be replaced with:
if ( ! bson_append_estart( b , bson_bindata , name , 4+1+len ) ) return 0;
bson_append32(b, &len);
Because the first 32-bit of a binary must only account for the size of the binary data itself.
BTW, it would be nice to have a way to append an binary array (that is, bindata subtype 2, see http://www.mongodb.org/display/DOCS/BSON#BSON-noteondatabinary) without preencoding the "str" argument of bson_append_binary.