Re: Determining how the app is run (intel/ppc/rosetta/os version)?
Re: Determining how the app is run (intel/ppc/rosetta/os version)?
- Subject: Re: Determining how the app is run (intel/ppc/rosetta/os version)?
- From: Sherm Pendley <email@hidden>
- Date: Sun, 21 May 2006 14:02:49 -0400
On May 21, 2006, at 9:25 AM, Gerben Wierda wrote:
My guess is that it was negative because I got an NSData whith a
length which was several millions or billions which if I remember
correctly in 2 bits complement is equivalent to a small (now that I
think of it, is this correct?
Yes, it is. A signed number uses the high bit to indicate the sign -
0=positive, 1=negative. If such a number is misinterpreted as
unsigned, the high bit is read as part of the number, resulting in a
Value of Unusual Size. VUSes are quite often a sign that, somewhere,
a signed/unsigned mixup has happened, so your guess is a very good one.
I shoul ddouble check the value before drawing such tentative
conclusions/guessing my way around) negative value.
So, 'putting it shortly' I am getting an NSData object that should
contain a small chunk of stderr output from my subprocess (received
via a named pipe by a separate thread to get around
AutorizationExecuteWithPrivileges limitations) with a length of 20
or so. Instead, I get an object which says it has length of several
million/billion bytes or so (plain silly), but not really random
lengths, they all are 'huge' and they felt like unsigned
interpretations of signed negative values to me. This object also
produces a nil NSString when used to convert it to a string. In
other words, the NSData object is corrupted.
Have you tried typecasting the value to an unsigned, and using it to
try to make a "good" copy of your data?
NSData *goodData = [NSData dataWithBytes:[badData bytes] length:
(unsigned)[badData length]];
My thinking is, the length is bogus, but the bytes might not be, and
since the length is explicitly passed in to the factory method above,
that method might not do a bounds check.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden