diff options
author | peter <peter@FreeBSD.org> | 2003-10-26 04:36:47 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2003-10-26 04:36:47 +0000 |
commit | 7f6ed48f658999a5345b7e16993c1b02ba03dc1d (patch) | |
tree | 0eaea6a2b7e5b3bfdb9d5a5f1977ca421f2c9756 /sbin | |
parent | b35f301d40f8b5c56a1b6afb9637f22e6c33001d (diff) | |
download | FreeBSD-src-7f6ed48f658999a5345b7e16993c1b02ba03dc1d.zip FreeBSD-src-7f6ed48f658999a5345b7e16993c1b02ba03dc1d.tar.gz |
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.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 907a5a7..0e433a5 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -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); |