Re: Problem parsing file in 64 bit build.
Re: Problem parsing file in 64 bit build.
- Subject: Re: Problem parsing file in 64 bit build.
- From: Graham Cox <email@hidden>
- Date: Tue, 08 May 2012 09:35:42 +1000
Understood, but in this case I'm not writing anything. I'm reading a file into a NSData, and using these structs to put a frame onto the data in places so I can extract data from the fields.
The alternative would be to pull out each data field one by one, which I'm sure is also considered acceptable practice, but for this file type, using structs has proved to be a lot easier, not least because of a) the strange mix of big-endian and little-endian values in the same file and b) the presence of directly formatted 'double' values that are not platform independent.
Some discussion of the merit of #pragma pack(n) versus other methods would be useful here, it's not something I've had to deal with very much.
--Graham
On 08/05/2012, at 3:43 AM, Stephen J. Butler wrote:
> On Mon, May 7, 2012 at 8:06 AM, Charles Srstka <email@hidden> wrote:
>> Myself, I like to just spin off a method or function that takes a chunk of data and populates the fields of the struct one by one, instead of writing the data straight onto the struct. A little more code, but you know it’s going to work right without any surprises.
>
> Not only that, but writing structs to file handles has caused security
> problems before. Consider what happens if you have a short or byte
> field and the compiler pads the struct. Now there's memory in your
> struct that never gets initialized. If you write that to a file or
> socket you're sending whatever might have been lurking there.
> Passwords, login details...
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden