• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Feeding NSUnarchiver bad data can cause crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feeding NSUnarchiver bad data can cause crash


  • Subject: Re: Feeding NSUnarchiver bad data can cause crash
  • From: "Douglas A. Welton" <email@hidden>
  • Date: Thu, 03 Jun 2004 11:10:43 -0400

on 6/3/04 9:00 AM, Jeremy Dronfield at email@hidden wrote:

> 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 unarchiveObjectWithData: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]).

Jeremy,

When you say, "it doesn't work" do you mean that an exception not thrown OR
do you mean that your code did not do what it was supposed to do? The code
I enclosed in my last e-mail is a snip from a working application, so I know
that what it does indeed work.

If you want a -canBeUnarchived: method, perhaps you might just try
implementing your own. Something like this should work...

- (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.

later,

douglas
_______________________________________________
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.


  • Follow-Ups:
    • Re: Feeding NSUnarchiver bad data can cause crash
      • From: Shawn Erickson <email@hidden>
    • Re: Feeding NSUnarchiver bad data can cause crash
      • From: Jeremy Dronfield <email@hidden>
    • Re: Feeding NSUnarchiver bad data can cause crash
      • From: Ondra Cada <email@hidden>
References: 
 >Re: Feeding NSUnarchiver bad data can cause crash (From: Jeremy Dronfield <email@hidden>)

  • Prev by Date: Re: Ugly bug in Foundation, beware!
  • Next by Date: Problems linking a standalone Java Cocoa app
  • Previous by thread: Re: Feeding NSUnarchiver bad data can cause crash
  • Next by thread: Re: Feeding NSUnarchiver bad data can cause crash
  • Index(es):
    • Date
    • Thread