Revision: 29818
          http://sourceforge.net/p/bibdesk/svn/29818
Author:   hofman
Date:     2025-11-16 09:32:11 +0000 (Sun, 16 Nov 2025)
Log Message:
-----------
catch exceptions from secure decoding

Modified Paths:
--------------
    trunk/bibdesk/BDSKFileSearchIndex.m
    trunk/bibdesk/BDSKSharedGroup.m
    trunk/bibdesk/BibItem.m

Modified: trunk/bibdesk/BDSKFileSearchIndex.m
===================================================================
--- trunk/bibdesk/BDSKFileSearchIndex.m 2025-11-15 17:58:11 UTC (rev 29817)
+++ trunk/bibdesk/BDSKFileSearchIndex.m 2025-11-16 09:32:11 UTC (rev 29818)
@@ -224,7 +224,8 @@
     NSData *data = [NSData dataWithContentsOfURL:aURL 
options:NSDataReadingMapped error:NULL];
     if (data) {
         NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] 
initForReadingFromData:data error:NULL];
-        isIndexCache = [[unarchiver decodeObjectOfClass:[NSURL class] 
forKey:@"documentURL"] isEqual:documentURL];
+        @try { isIndexCache = [[unarchiver decodeObjectOfClass:[NSURL class] 
forKey:@"documentURL"] isEqual:documentURL]; }
+        @catch(id e) {}
         [unarchiver finishDecoding];
     }
     return isIndexCache;
@@ -496,11 +497,13 @@
     if (indexCacheURL) {
         
         NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] 
initForReadingFromData:[NSData dataWithContentsOfURL:indexCacheURL] error:NULL];
-        indexData = [[unarchiver decodeObjectOfClass:[NSData class] 
forKey:@"indexData"] mutableCopy];
+        @try{ indexData = [[unarchiver decodeObjectOfClass:[NSData class] 
forKey:@"indexData"] mutableCopy]; }
+        @catch(id e) {}
         if (indexData != NULL) {
             tmpIndex = SKIndexOpenWithMutableData((__bridge 
CFMutableDataRef)indexData, NULL);
             if (tmpIndex) {
-                [signatures setDictionary:[unarchiver 
decodeObjectOfClasses:[NSSet setWithObjects:[NSDictionary class], [NSString 
class], [NSData class], [NSData class], nil] forKey:@"signatures"]];
+                @try{ [signatures setDictionary:[unarchiver 
decodeObjectOfClasses:[NSSet setWithObjects:[NSDictionary class], [NSString 
class], [NSData class], [NSData class], nil] forKey:@"signatures"]]; }
+                @catch(id e) {}
             } else {
                 indexData = nil;
             }

Modified: trunk/bibdesk/BDSKSharedGroup.m
===================================================================
--- trunk/bibdesk/BDSKSharedGroup.m     2025-11-15 17:58:11 UTC (rev 29817)
+++ trunk/bibdesk/BDSKSharedGroup.m     2025-11-16 09:32:11 UTC (rev 29818)
@@ -179,13 +179,16 @@
     if (pubsArchive) {
         BDSKKeyedUnarchiver *unarchiver = [[BDSKKeyedUnarchiver alloc] 
initForReadingFromData:pubsArchive error:NULL];
         [unarchiver setMacroResolver:[self macroResolver]];
-        pubs = [unarchiver decodeObjectOfClasses:[NSSet 
setWithObjects:[NSArray class], [BibItem class], nil] 
forKey:NSKeyedArchiveRootObjectKey];
+        @try{ pubs = [unarchiver decodeObjectOfClasses:[NSSet 
setWithObjects:[NSArray class], [BibItem class], nil] 
forKey:NSKeyedArchiveRootObjectKey]; }
+        @catch(id e) {}
         [unarchiver finishDecoding];
     }
     if (macrosArchive) {
         BDSKKeyedUnarchiver *unarchiver = [[BDSKKeyedUnarchiver alloc] 
initForReadingFromData:pubsArchive error:NULL];
         [unarchiver setMacroResolver:[self macroResolver]];
-        NSDictionary *dict = [unarchiver decodeObjectOfClasses:[NSSet 
setWithObjects:[NSDictionary class], [NSString class], nil] 
forKey:NSKeyedArchiveRootObjectKey];
+        NSDictionary *dict = nil;
+        @try{ dict = [unarchiver decodeObjectOfClasses:[NSSet 
setWithObjects:[NSDictionary class], [NSString class], nil] 
forKey:NSKeyedArchiveRootObjectKey]; }
+        @catch(id e) {}
         [unarchiver finishDecoding];
         if (dict) {
             macros = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
capacity:0];

Modified: trunk/bibdesk/BibItem.m
===================================================================
--- trunk/bibdesk/BibItem.m     2025-11-15 17:58:11 UTC (rev 29817)
+++ trunk/bibdesk/BibItem.m     2025-11-16 09:32:11 UTC (rev 29818)
@@ -493,10 +493,12 @@
 + (NSArray *)publicationsFromPasteboard:(NSPasteboard *)pboard 
macroResolver:(BDSKMacroResolver *)aMacroResolver {
     NSData *data = [pboard dataForType:BDSKPasteboardTypePublications];
     BDSKKeyedUnarchiver *unarchiver = [[BDSKKeyedUnarchiver alloc] 
initForReadingFromData:data error:NULL];
+    NSArray *pubs = nil;
     
     [unarchiver setMacroResolver:aMacroResolver];
     
-    NSArray *pubs = [unarchiver decodeObjectOfClasses:[NSSet 
setWithObjects:[NSArray class], [BibItem class], nil] forKey:@"publications"];
+    @try { pubs = [unarchiver decodeObjectOfClasses:[NSSet 
setWithObjects:[NSArray class], [BibItem class], nil] forKey:@"publications"]; }
+    @catch (id e) {}
     
     [unarchiver finishDecoding];
     

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to