aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2004-09-02 22:10:57 +0000
committerH. Peter Anvin <hpa@zytor.com>2004-09-02 22:10:57 +0000
commit96da4f968194ec65e5a5682c18659cb7ef93aa4b (patch)
treefdf303a8e767cdba7a988a7bb26769ae11d919fe
parent65eb86d049b93a6d35d935bf33436c569667756f (diff)
downloadklibc-96da4f968194ec65e5a5682c18659cb7ef93aa4b.tar.gz
Don't modify the length of an option - parse failure results. Bug fixklibc-0.172
from Olaf Hering.
-rw-r--r--ipconfig/bootp_proto.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/ipconfig/bootp_proto.c b/ipconfig/bootp_proto.c
index 7e6936c54f785..7c8a2889edf9a 100644
--- a/ipconfig/bootp_proto.c
+++ b/ipconfig/bootp_proto.c
@@ -89,19 +89,13 @@ bootp_parse(struct netdev *dev, struct bootp_hdr *hdr, __u8 *exts, int extlen)
switch (opt) {
case 1: /* subnet mask */
- if (len > 4)
- len = 4;
- memcpy(&dev->ip_netmask, ext, len);
+ memcpy(&dev->ip_netmask, ext, len > 4 ? 4 : len);
break;
case 3: /* default gateway */
- if (len > 4)
- len = 4;
- memcpy(&dev->ip_gateway, ext, len);
+ memcpy(&dev->ip_gateway, ext, len > 4 ? 4 : len);
break;
case 6: /* DNS server */
- if (len > 8)
- len = 8;
- memcpy(&dev->ip_nameserver, ext, len);
+ memcpy(&dev->ip_nameserver, ext, len > 8 ? 8 : len);
break;
case 12: /* host name */
if (len > sizeof(dev->hostname) - 1)
@@ -126,9 +120,7 @@ bootp_parse(struct netdev *dev, struct bootp_hdr *hdr, __u8 *exts, int extlen)
dev->mtu = (ext[0] << 8) + ext[1];
break;
case 28: /* broadcast addr */
- if (len > 4)
- len = 4;
- memcpy(&dev->ip_broadcast, ext, len);
+ memcpy(&dev->ip_broadcast, ext, len > 4 ? 4 : len);
break;
case 40: /* NIS domain name */
if (len > sizeof(dev->nisdomainname) - 1)