From 068d43dca5fee9b33a502e81b23525c86ec9fdb9 Mon Sep 17 00:00:00 2001 From: tholo <> Date: Thu, 24 Apr 1997 08:35:21 +0000 Subject: Pad out trailing parts of the address with zeros so we get a legal network address when only the first octets are given (eg. 140.174 ==> 140.174.0.0) --- src/lib/libc/net/inet_network.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libc/net/inet_network.c b/src/lib/libc/net/inet_network.c index 34682bbec1..a5360b7252 100644 --- a/src/lib/libc/net/inet_network.c +++ b/src/lib/libc/net/inet_network.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: inet_network.c,v 1.5 1997/04/05 21:13:14 millert Exp $"; +static char rcsid[] = "$OpenBSD: inet_network.c,v 1.6 1997/04/24 08:35:21 tholo Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -83,9 +83,10 @@ again: return (INADDR_NONE); *pp++ = val; n = pp - parts; - for (val = 0, i = 0; i < n; i++) { + for (val = 0, i = 0; i < 4; i++) { val <<= 8; - val |= parts[i] & 0xff; + if (i < n) + val |= parts[i] & 0xff; } return (val); } -- cgit v1.2.3-55-g6feb