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: "Douglas A. Welton" <email@hidden>
- Date: Wed, 02 Jun 2004 16:27:10 -0400
Jeremy,
Check out the section on "Handling Exceptions" in the Cocoa doc. NS_DURING,
NS_HANDLER, and NS_ENDHANDLER are your friend ;^}
see
<
http://developer.apple.com/documentation/Cocoa/Conceptual/Exceptions/Tasks/
HandlingExceptions.html>
later,
douglas
on 6/2/04 12:44 PM, Jeremy Dronfield at email@hidden wrote:
>
If you provide NSUnarchiver with data which is not unarchivable, an
>
error results. Using the class method +unarchiveObjectWithData: with
>
bad data produces a warning:
>
>
*** +[NSUnarchiver unarchiveObjectWithData:]: extra data discarded
>
>
Sometimes - maybe about 1 in 100 - this causes a crash. Using the
>
designated initializer, -initForReadingWithData: followed by
>
-decodeObject does not produce a warning, but does produce a crash with
>
about the same frequency, described as
>
>
*** malloc_zone_malloc[414]: argument too large: 4294967286
>
>
Obviously, the solution is not to feed NSUnarchiver bad data. But given
>
that bad data happens, and a crash can result, why isn't there a method
>
like -[NSData canBeUnarchived] for use in situations where bad data
>
might be a risk? Does anyone know of a workaround which could provide a
>
comparable check?
>
>
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.