Re: File load magic misfeature and workaround

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Marc Lehmann wrote:
> 
> On Wed, Dec 29, 1999 at 04:43:20PM +1100, David Hodson <hodsond@xxxxxxxxxxxxxx> wrote:
> > the value to check is loaded into a (signed) int variable, and strtol()
> > The easy workaround is to search for a four-byte string value instead.
> 
> It would occur to me that the real problem is strtol overflowing. Why does
> strtol overflow at all? POSIX requires strtol to be able to convert _all_
> long values.

Well, specifying a magic of "0,long,0x802A5FD7" calls
strtol("0x802A5FD7"),
which returns MAX_LONG (0x7FFFFFFF) (and presumably an error). strtoul()
might work better, but as I said, I didn't want to break anyone else's
magic numbers.

> Would specifying the right (signed) constant help?

Maybe. But bits is bits, you know.

> If you think all this should be documented somewhere, then you are
> definitely right ;)

Agreed.

-- 
David Hodson  --  hodsond@xxxxxxx  --  this night wounds time


[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux