From: tholo Date: Thu, 24 Apr 1997 08:35:21 +0000 (+0000) Subject: Pad out trailing parts of the address with zeros so we get a legal network X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5dbce1d97deebbaba04badbf3ff7c6641e4db889;p=openbsd 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) --- diff --git a/lib/libc/net/inet_network.c b/lib/libc/net/inet_network.c index 34682bbec16..a5360b72522 100644 --- a/lib/libc/net/inet_network.c +++ b/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); }