• 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: Jeremy Dronfield <email@hidden>
  • Date: Thu, 3 Jun 2004 17:05:23 +0100

On 3 Jun 2004, at 3:02 pm, Ian Clark wrote:

I think that NSUnarchiver will return nil if it doesn't like the data format that it is given.

I only wish it did. I could handle that.

Eg. Some time ago Chris Kane wrote: (regarding the old pre 10.2 format)

NSUnarchiver will return nil there if the archive version/magic "number" is unknown to it (it knows the ones it can deal with); one example would be, the file isn't really an NSArchiver archive.

This magic is one of 0x3 or 0x4 followed by 0xb followed by "typedstream" or "streamtyped" at the beginning of the file.

Your problem seems more like a (de)coding error in your (un)archiving methods. eg.
Failure to retain an decoded object.
Deallocating something being archived while the archiver is running, so that archiving pass 2 sees a different object at an address to that which it saw during pass 1.

No, I'm sure it isn't any of these. In a loop, where the unarchiver is handed good data in exactly the same way, it will unarchive happily over and over again until it's blue in the face.

The setup I'm using is this. An attributed string is archived, and the archived data is encrypted using a Blowfish symmetric cipher, producing a second data object which is saved to disk. Later, the encrypted data is decrypted. If the key used for decryption is the wrong one, the data will decrypt, but will be "bad" data. If this is passed to an NSUnarchiver for unarchiving as an attributed string, the unarchiver forces it to unarchive, resulting an error:

*** +[NSUnarchiver unarchiveObjectWithData:]: extra data discarded

and, sometimes, a SIGNAL 11 crash:

*** malloc_zone_malloc[414]: argument too large: 4294967286

If exactly the same encrypted data is decrypted with the correct key, producing "good" data, it unarchives just fine, never crashes, and all is cool.

The magic numbers you mention would be extremely useful if I knew how to access them. Perhaps it's possible to parse the decrypted data to see if the magic number is there? Or is it only present when the archive is written to file? In my case, it's the encrypted archive, not the archive itself, which is saved to disk.

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.


  • Follow-Ups:
    • Re: Feeding NSUnarchiver bad data can cause crash
      • From: "Louis C. Sacha" <email@hidden>
    • Re: Feeding NSUnarchiver bad data can cause crash
      • From: Glenn Andreas <email@hidden>
  • Prev by Date: Re: Debugging under 10.2
  • Next by Date: Re: Feeding NSUnarchiver bad data can cause crash
  • Previous by thread: Re: embedding the DisclosableView framework
  • Next by thread: Re: Feeding NSUnarchiver bad data can cause crash
  • Index(es):
    • Date
    • Thread