Fix off-by-one in app group identifier length check for POSIX semaphore prefix#113
Open
taichino wants to merge 2 commits intoobjectbox:mainfrom
Open
Fix off-by-one in app group identifier length check for POSIX semaphore prefix#113taichino wants to merge 2 commits intoobjectbox:mainfrom
taichino wants to merge 2 commits intoobjectbox:mainfrom
Conversation
Member
|
Thanks for this! We should probably also change this to work like in the Dart API where a missing slash suffix is added before the length check. For our reference this is internal issue |
Author
|
Thanks for the suggestion! I've updated the PR to match the Dart API approach. |
Member
|
@taichino I didn't expect you to make these changes (hence the "we" as in the ObjectBox team), so thank you! We will look at picking these changes when there is time! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On sandboxed macOS,
Store.initreads the app's entitlements and picks the firstapplication group identifier that fits within the POSIX semaphore name budget.
The current filter checks
$0.length <= 20before appending "/", butobx_posix_sem_prefix_setrequires the total prefix (including "/") to be at most20 characters. A group ID of exactly 20 characters passes the filter, becomes 21
after appending, and is rejected by the C library.
The rejected call sets thread-local error state, and because the return value of
obx_posix_sem_prefix_setis not checked, this stale error propagates intoStore.initviacheckLastError(), causing initialization to fail withillegalArgument("Given prefix must not exceed 20 chars").This was discovered in a production app whose shortest app group identifier is
exactly 20 characters (team ID + "." + 9-char name).
Changes
<= 20to<= 19to account for the appended "/"Testing
This is not covered by a unit test because
setUpMutexIdentifierreads entitlementsfrom the running binary's code signature at runtime, which cannot be controlled in a
test environment. The fix is verified by code inspection.