-
Type: Bug
-
Resolution: Won't Fix
-
Priority: Major - P3
-
Affects Version/s: 0.6
-
Component/s: None
-
None
-
Environment:32bit Linux
Server: http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.2.0.tgz
Client: https://github.com/mongodb/mongo-c-driver/zipball/v0.6
Running "tutorial_empty_query" from http://api.mongodb.org/c/current/tutorial.html on an empty database, I see that not enough memory is allocated for "out" in mongo_read_response (src/mongo.c). I added a printf:
printf("mongo_read_response: %d required, %d allocated\n", sizeof(mongo_reply), len);
out = ( mongo_reply * )bson_malloc( len ); // was here before
And the output I get (tutorial_empty_query on empty database):
mongo_read_response: 37 required, 106 allocated
mongo_read_response: 37 required, 36 allocated // from mongo_cursor_next( cursor )
In mongo_read_response (src/mongo.c) the check for "len" is:
len < sizeof( head )+sizeof( fields )
Seems mongo_reply.objs is missing. Wouldn't something like:
len < sizeof(mongo_reply)
be better? But this is just a check that fails to catch the problem. I guess the actual problem is that the requested "len" is too small. Not sure where that comes from.