[CDRIVER-4234] Build failure on Mac OS X 10.6 due to use of arc4random_buf Created: 25/Nov/21 Updated: 28/Oct/23 Resolved: 13/Dec/21 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libbson |
| Affects Version/s: | 1.20.0 |
| Fix Version/s: | 1.20.1 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Ryan Schmidt | Assignee: | Kevin Albertson |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
I can't build libbson from mongo-c-driver 1.20.0 on Mac OS X 10.6.8 with Apple clang version 1.7 (tags/Apple/clang-77) (based on LLVM 2.9svn) from Xcode 3.2.6. The error is:
This problem was introduced in https://github.com/mongodb/mongo-c-driver/pull/723 by unconditionally using arc4random_buf on macOS. arc4random_buf was introduced in Mac OS X 10.7. This made me look at the code in _get_rand which raised a few questions:
Assuming the answer to both questions is that there is no good reason, I propose the following modification to address these issues: |
| Comments |
| Comment by Githook User [ 13/Dec/21 ] |
|
Author: {'name': 'Ryan Schmidt', 'email': 'ryandesign@macports.org', 'username': 'ryandesign'}Message: |
| Comment by Githook User [ 13/Dec/21 ] |
|
Author: {'name': 'Ryan Schmidt', 'email': 'ryandesign@macports.org', 'username': 'ryandesign'}Message: |
| Comment by Ryan Schmidt [ 12/Dec/21 ] |
|
Ok they're separated now. |
| Comment by Ryan Schmidt [ 12/Dec/21 ] |
|
I should probably separate the second commit into two... |
| Comment by Ryan Schmidt [ 12/Dec/21 ] |
|
Sure, is this ok? |
| Comment by Kevin Albertson [ 12/Dec/21 ] |
|
I do not have a Mac OS X 10.6 handy to test building. But comparing Libc versions in https://opensource.apple.com/releases/ shows arc4random_buf introduced in stdlib.h in OS X 10.7:
I do not see a clear reason. I agree it is preferable to check for arc4random_buf at configure time.
I do not see a clear reason. arc4random_buf seems preferable to rand_r.
Thank you for including the patch! The patch LGTM and it applies cleanly on the latest commit (0756cbb4470a797be7d70841a7c922643dd30d55). Would you like to submit a pull-request? If not, I am happy to put it up for review. |