UnrarKit icon indicating copy to clipboard operation
UnrarKit copied to clipboard

Error resolving bookmark to RAR archive: Error Domain=NSCocoaErrorDomain Code=4 "The file doesn’t exist."

Open luisangelsm opened this issue 2 years ago • 0 comments

I have found a crash when trying to extract RAR files with this library.

Steps to reproduce issue (Detailed enough for me to reproduce - attaching a sample archive can be very helpful):

Sadly it is not easy to reproduce, it is something that happens using iTunes on Windows, transferring a file to an app using "File Sharing" and the file name contains some unicode characters, e.g. û.

What you expect to happen:

The file is extracted.

What actually happened:

A crash.

A stack trace or crash report, if you have one:

The problem happens when - (NSURL *)fileURL fails to get the URL in

NSURL *result = [NSURL URLByResolvingBookmarkData:self.fileBookmark
                                                                                  options:0
                                                                       relativeToURL:nil
                                                          bookmarkDataIsStale:&bookmarkIsStale
                                                                                     error:&error];

The method returns nil and that nil ends in - (BOOL)_unrarOpenFile:(NSString *)rarFile inMode:(NSInteger)mode withPassword:(NSString *)aPassword error:(NSError * __autoreleasing *)error causing a crash here self.flags->ArcName = strdup(rarFile.UTF8String);

The library should check if rarFile is nil to avoid the crash.

BUT, it would be nice to find and fix the underlying error that causes NSURL URLByResolvingBookmarkData to fail with Error Domain=NSCocoaErrorDomain Code=4 "The file doesn’t exist."

luisangelsm avatar Apr 22 '23 13:04 luisangelsm