Re: Feeding NSUnarchiver bad data can cause crash
Re: Feeding NSUnarchiver bad data can cause crash
- Subject: Re: Feeding NSUnarchiver bad data can cause crash
- From: Jeremy Dronfield <email@hidden>
- Date: Thu, 3 Jun 2004 14:00:39 +0100
On 3 Jun 2004, at 12:14 pm, Douglas A. Welton wrote:
NS_DURING
Library = [[NSUnarchiver unarchiveObjectWithFile: Target_File]
retain];
NS_HANDLER
//+
// Put up an error dialog for the user and perform
// an alternate initialization for the Library
//-
NSBeginInformationalAlertSheet( @"Oak Library", @"Continue", nil,
nil,
Main_Window, nil, NULL, NULL, nil,
@"Error message goes here" );
Library = [[[Oak_Sources alloc] init] retain];
NS_ENDHANDLER
Hi Douglas
Yes, I tried something like this before. My version (suited to the
particular case, where I'm passing the unarchiver decrypted data
retrieved from an encrypted property list) is this:
NS_DURING
theText = [NSUnarchiver unarchiveObjectWith
Data:plaintext]; // CRASH!!
NS_HANDLER
if ([[localException name] isEqualToString:NSMallocException])
NSLog(@"malloc exception");
theText = nil;
success = NO;
NS_ENDHANDLER
It doesn't work. The error isn't handled. This is why I lament the lack
of an ability to do something like, if ([plaintext canBeUnarchived])
or, if ([plaintext conformsToArchiving]).
Regards,
-Jeremy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.