Ethereal-dev: Re: [Ethereal-dev] Some Mandrake 64 bit fixes

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: "Guy Harris" <[email protected]>
Date: Fri, 16 Jul 2004 16:40:47 -0700 (PDT)
(Are you checking a bunch of Linux distributions for fixes?  If so, don't
forget the non-commercial ones - and take a look at the {Free,Net,Open}BSD
ports collections as well.)

Joerg Mayer said:
> ... which I didn't apply because I'm not sure that intttype.h is portable.

I suspect it might not be.  I suspect most modern UN*Xes have it, but I'm
not sure how modern "modern" is, so there might be OS versions that people
are using that don't support it, and I don't know whether Windows or the
header file collections for various Windows C/C++ compilers have it.

In any case, comparing against {U}INT32_MAX is the wrong thing to do
anyway - "strto{u}l()" returns {U}LONG_MAX on overflow and, for
"strtol()", LONG_MIN on underflow.

However:

    1) I'm not sure they're guaranteed to clear "errno" on success, so we
should clear it before calling "strtol{u}l()" if we're going to check
"errno" afterwards;

    2) their return values should be assigned to "{unsigned} long"
variables, so we don't lose bits, and those variables should be
checked against the maximum (and minimum, for "strtol()") values for a
"g{u}int32" as well (GLib 2.4 appears to have #defines for those; I
don't know about GLib 1.2 - I'll check that at home) and only if all
tests succeed should we assign that variable to the final destination.

I've checked those changes in.