summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1997-04-24 08:35:22 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1997-04-24 08:35:22 +0000
commita4eda05215c4d308e4af6fd94932913efeab562e (patch)
treeee5130989dd7c504c9447a801d40c2259d04a913 /lib
parent7a00c463b7512f0d070e6be79bcd0b964d40c316 (diff)
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)
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/net/inet_network.c7
1 files changed, 4 insertions, 3 deletions
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 <sys/types.h>
@@ -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);
}