deviceid / diveid weirdness

Dirk Hohndel dirk at hohndel.org
Fri Nov 22 13:22:52 UTC 2013


On Fri, 2013-11-22 at 13:12 -0800, Linus Torvalds wrote:
> On Fri, Nov 22, 2013 at 12:48 PM, Dirk Hohndel <dirk at hohndel.org> wrote:
> >
> > Some users get deviceid and diveid entries above 0x80000000 "truncated"
> > into 0x7fffffff. But apparently only after downloading additional dives
> > on top of existing ones.
> 
> Ugh.
> 
> I think we need to fix hex_value() in parse-xml.c to use "strtoul()".
> 
> The problem is hidden on 64-bit builds.

strtoul() is supposed to return unsigned long int. Which on a 32bit
architure is supposed to be 32bit.

Our IDs are max 8 hex digits. So nothing should overflow.

And even if it did... strtoul returns ULONG_MAX when things overflow...
that doesn't explain why we are getting 32bit LONG_MAX as result :-(

/D



More information about the subsurface mailing list