Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feeding NSUnarchiver bad data can cause crash



Douglas,

On 3.6.2004, at 17:10, Douglas A. Welton wrote:

> implementing your own. Something like this should work...

Not using the return statements this way:

> - (BOOL)canBeUnarchived: (NSData *)Target_Data
> {
> id Archive;
> NS_DURING
> Archive = [NSUarchiver unarchiveObjectWithData: Target_Data]
> return YES;
> NS_HANDLER
> return NO;
> NS_ENDHANDLER
> }
>
> ... note the standard disclaimers apply.

Especially, don't ever use return inside of NS_... blocks. Either go
@try, or use NS_VALUERETURN (or whatever it is called, I can't recall
the very now), or--the best way IMHO--store the result into a variable:

BOOL okay=NO;
NS_DURING
...
okay=YES;
NS_HANDLER ... NS_ENDHANDLER
return okay;
---
Ondra Hada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.


References: 
 >Re: Feeding NSUnarchiver bad data can cause crash (From: "Douglas A. Welton" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.