Give wider types to sscanf to fix two warnings (u_short cannot be > 0xffff)

and to make sure that we catch oversized arguments rather than silently
truncate them.  I dont know if sscanf will reject an integer if it will
not fit in the short return variable or not, but this way it should be
detected.
This commit is contained in:
Peter Wemm 2003-10-26 04:36:47 +00:00
parent d988f6deec
commit 566214a32a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=121539

View File

@ -1687,9 +1687,9 @@ void
setatrange(const char *range, int dummy __unused, int s,
const struct afswtch *afp)
{
u_short first = 123, last = 123;
u_int first = 123, last = 123;
if (sscanf(range, "%hu-%hu", &first, &last) != 2
if (sscanf(range, "%u-%u", &first, &last) != 2
|| first == 0 || first > 0xffff
|| last == 0 || last > 0xffff || first > last)
errx(1, "%s: illegal net range: %u-%u", range, first, last);