[CDRIVER-8] bson_append_binary produces bogus data Created: 24/Jan/10 Updated: 19/Oct/16 Resolved: 25/Jan/10 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 0.2 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Rui Lopes | Assignee: | Mathias Stearn |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
The following lines: const int size = 4+1+len; Should be replaced with: if ( ! bson_append_estart( b , bson_bindata , name , 4+1+len ) ) return 0; 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. |
| Comments |
| Comment by Rui Lopes [ 26/Jan/10 ] |
|
Because of this note on the spec page: Note that 0x02 is the commonly used "binary" type for carrying general binary data I though it was the way to encode an opaque binary array. Is there a preferred way? Maybe with subtype 0x80? |
| Comment by Mathias Stearn [ 25/Jan/10 ] |
|
Why do you need to use subtype 2? bson_iterator_bin_len() should be the same number that would be prefixed to the real data. Just store the array directly. If you really need a helper for subtype 2 please open a new case. |
| Comment by auto [ 25/Jan/10 ] |
|
Author: {'login': 'RedBeard0531', 'name': 'Mathias Stearn', 'email': 'redbeard0531@gmail.com'}Message: Fix bson_append_binary |