[CDRIVER-2693] Segfault in bson_b64_pton parsing valid BSON Created: 09/Jun/18 Updated: 28/Oct/23 Resolved: 12/Jun/18 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libbson |
| Affects Version/s: | 1.10.2 |
| Fix Version/s: | 1.10.3 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Dan Bauman | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
CentOS 7 |
||
| Attachments: |
|
||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Description |
|
installed via
bson_new_from_json calls bson_json_reader_read calls jsonsl_feed calls bson_b64_pton
segfaults on line
|
| Comments |
| Comment by Githook User [ 12/Jun/18 ] | |||||||||
|
Author: {'username': 'ajdavis', 'name': 'A. Jesse Jiryu Davis', 'email': 'jesse@mongodb.com'}Message: The function relies on data that is initialized by mongoc_init, but a | |||||||||
| Comment by Githook User [ 12/Jun/18 ] | |||||||||
|
Author: {'username': 'ajdavis', 'name': 'A. Jesse Jiryu Davis', 'email': 'jesse@mongodb.com'}Message: The function relies on data that is initialized by mongoc_init, but a
| |||||||||
| Comment by A. Jesse Jiryu Davis [ 12/Jun/18 ] | |||||||||
|
Needs backport to 1.10.3. | |||||||||
| Comment by A. Jesse Jiryu Davis [ 11/Jun/18 ] | |||||||||
|
A kind of primitive global static bool "b64rmap_initialized" saved the libbson version from this; the libmongoc version had no such check whether the map was initialized, and when we merged the repos we took libmongoc's version. | |||||||||
| Comment by Githook User [ 11/Jun/18 ] | |||||||||
|
Author: {'username': 'ajdavis', 'name': 'A. Jesse Jiryu Davis', 'email': 'jesse@mongodb.com'}Message: The function relies on data that is initialized by mongoc_init, but a | |||||||||
| Comment by A. Jesse Jiryu Davis [ 09/Jun/18 ] | |||||||||
|
Thanks Dan, that's a useful investigation. We need to guard initialization of the map with more than just a global boolean, as you realize. bson_context_get_default() has a good example of the technique:
The function "bson_once" is defined as InitOnceExecuteOnce on Windows and pthread_once everywhere else. | |||||||||
| Comment by Dan Bauman [ 09/Jun/18 ] | |||||||||
|
this patch works for my needs I realize there are some threading/performance considerations when iintegrated with Mongo-c-driver
| |||||||||
| Comment by Dan Bauman [ 09/Jun/18 ] | |||||||||
|
the b64 map isn't initialized
seems to do the trick, but need a good place to call it, but it's private and can't find a libbson init function
doesn't get run when using libbson disconnected from the c driver
|