[CDRIVER-170] bson_iterator_bin_data returns a pointer 4 bytes before the actual data Created: 26/Sep/12  Updated: 03/May/17  Resolved: 14/Nov/12

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: mog Assignee: Gary Murakami
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

It seams that the 'BSON_BIN_BINARY_OLD' test is swapped between length and data function :

MONGO_EXPORT int bson_iterator_bin_len( const bson_iterator *i ) {
return ( bson_iterator_bin_type( i ) == BSON_BIN_BINARY_OLD )
? bson_iterator_int_raw( i ) - 4
: bson_iterator_int_raw( i );
}

MONGO_EXPORT const char *bson_iterator_bin_data( const bson_iterator *i ) {
return ( bson_iterator_bin_type( i ) == BSON_BIN_BINARY_OLD )
? bson_iterator_value( i ) + 9
: bson_iterator_value( i ) + 5;
}



 Comments   
Comment by mog [ 26/Sep/12 ]

Sorry my bad, I checked the code, it's fine. The size I get as the first 4 bytes is obviously from my buffer.
It is misleading as it looks like the bson binary header but it definitely is on my side.

This can be closed, sorry for the inconvenience.

Generated at Wed Feb 07 21:08:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.