Skip to content

Commit

Permalink
Check len against underflow that could cause heap overrun
Browse files Browse the repository at this point in the history
Caught by Georg Wicherski of Kaspersky Labs
  • Loading branch information
RedBeard0531 committed Oct 22, 2010
1 parent e62001c commit 7afb6e4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/mongo.c
Expand Up @@ -293,6 +293,10 @@ mongo_reply * mongo_read_response( mongo_connection * conn ){
looping_read(conn, &fields, sizeof(fields));

bson_little_endian32(&len, &head.len);

if (len < sizeof(head)+sizeof(fields) || len > 64*1024*1024)
MONGO_THROW(MONGO_EXCEPT_NETWORK); /* most likely corruption */

out = (mongo_reply*)bson_malloc(len);

out->head.len = len;
Expand Down

0 comments on commit 7afb6e4

Please sign in to comment.