[Sandbox Configuration] Fix nil pointer issues

Solve some nil pointer issues with the Sandbox configuration code being
set with invalid paths.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
swiftingly
Christopher Snowhill 2022-06-21 16:12:28 -07:00
parent 5d3077963a
commit bc23ed6c24
1 changed files with 4 additions and 4 deletions

View File

@ -144,7 +144,7 @@ static SandboxBroker *kSharedSandboxBroker = nil;
- (SandboxEntry *)recursivePathTest:(NSURL *)url { - (SandboxEntry *)recursivePathTest:(NSURL *)url {
for(SandboxEntry *entry in storage) { for(SandboxEntry *entry in storage) {
if([SandboxBroker isPath:url aSubdirectoryOf:[NSURL fileURLWithPath:entry.path]]) { if(entry.path && [SandboxBroker isPath:url aSubdirectoryOf:[NSURL fileURLWithPath:entry.path]]) {
entry.refCount += 1; entry.refCount += 1;
return entry; return entry;
} }
@ -162,11 +162,9 @@ static SandboxBroker *kSharedSandboxBroker = nil;
if(results && [results count] > 0) { if(results && [results count] > 0) {
for(SandboxToken *token in results) { for(SandboxToken *token in results) {
if([SandboxBroker isPath:url aSubdirectoryOf:[NSURL fileURLWithPath:token.path]]) { if(token.path && [SandboxBroker isPath:url aSubdirectoryOf:[NSURL fileURLWithPath:token.path]]) {
SandboxEntry *entry = [[SandboxEntry alloc] initWithToken:token]; SandboxEntry *entry = [[SandboxEntry alloc] initWithToken:token];
[storage addObject:entry];
BOOL isStale; BOOL isStale;
NSError *err = nil; NSError *err = nil;
NSURL *secureUrl = [NSURL URLByResolvingBookmarkData:token.bookmark options:NSURLBookmarkResolutionWithSecurityScope relativeToURL:nil bookmarkDataIsStale:&isStale error:&err]; NSURL *secureUrl = [NSURL URLByResolvingBookmarkData:token.bookmark options:NSURLBookmarkResolutionWithSecurityScope relativeToURL:nil bookmarkDataIsStale:&isStale error:&err];
@ -177,6 +175,8 @@ static SandboxBroker *kSharedSandboxBroker = nil;
entry.secureUrl = secureUrl; entry.secureUrl = secureUrl;
[storage addObject:entry];
[secureUrl startAccessingSecurityScopedResource]; [secureUrl startAccessingSecurityScopedResource];
return entry; return entry;