In src/wtmpdb.c for last -N:
maxentries = maxentries * 10 + c - '0';
can yield an integer wrapping (maxentries is an unsigned integer, so not really an integer overflow, but unexpected wrapping).
For instance, last -18446744073709551617 outputs only 1 entry.
A fix could probably be something like that:
if (maxentries > (ULONG_MAX - (c - '0')) / 10)
maxentries = ULONG_MAX;
else
maxentries = maxentries * 10 + c - '0';
There is no such issue with -n because strtoul is used in this case.
In
src/wtmpdb.cforlast -N:can yield an integer wrapping (
maxentriesis an unsigned integer, so not really an integer overflow, but unexpected wrapping).For instance,
last -18446744073709551617outputs only 1 entry.A fix could probably be something like that:
There is no such issue with
-nbecausestrtoulis used in this case.