[NNTP] 32 bit article counters
Clive D.W. Feather
clive at demon.net
Thu Jul 14 08:07:56 PDT 2005
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.
> and note
> that there is no portable way to easily fix this code since there is no
> portable sscanf directive for reading a 64-bit article number that works
> on all of the platforms to which slrn has been ported.
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.
(Incidentally, the spaces can be omitted from the format specifiers in both
cases.)
--
Clive D.W. Feather | Work: <clive at demon.net> | Tel: +44 20 8495 6138
Internet Expert | Home: <clive at davros.org> | Fax: +44 870 051 9937
Demon Internet | WWW: http://www.davros.org | Mobile: +44 7973 377646
Thus plc | |
More information about the ietf-nntp
mailing list