[NNTP] 32 bit article counters

Russ Allbery rra at stanford.edu
Thu Jul 14 08:32:23 PDT 2005


Clive D W Feather <clive at demon.net> writes:
> Russ Allbery said:

>>    int estim;
>>    int min, max;
> [...]
>>         if (3 != sscanf(s->rspbuf + 4, "%d %d %d", &estim, &min, &max))

>> Note that this fails silently with 64-bit article numbers in ways that are
>> likely to cause unexpected behavior in the rest of the program,

> Actually, because it uses signed integers it will fail on some platforms
> anyway.

Yup, good point.

> On platforms supporting C99, this code should be written as:

>     uint_least64_t estim;
>     uint_least64_t min, max;
> [...]
>         if (3 != sscanf(s->rspbuf + 4,
>                         SCNuLEAST64 " " SCNuLEAST64 " " SCNuLEAST64,
>                         &estim, &min, &max))

> and will then work correctly on all such platforms.

Right.  However, the only platform I personally have handy (of seven) that
actually supports a sufficient amount of C99 for that to work is Linux.
Various necessary bits of the above are missing on everything else I have
handy.

You can make it work with Autoconf glue -- there aren't that many systems
left that don't have any 64-bit type whatsoever (although there are some,
particularly if one isn't using gcc).  My question is more, will enough
people do so in order to really make this an interoperable practice?

(I wonder how much software will fail at 31 bits, too.  I dug a lot of
signed integers for article numbers out of INN when I started doing
cleanups, and I think there are still a few left in the corners.)

-- 
Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>



More information about the ietf-nntp mailing list