summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortholo <>1997-04-24 08:35:21 +0000
committertholo <>1997-04-24 08:35:21 +0000
commit068d43dca5fee9b33a502e81b23525c86ec9fdb9 (patch)
tree880d59c503dcbc05fb944c9f48ffe6c65921aa81 /src/lib
parentda017e944cbdca423bc11e829ab905ef6836a898 (diff)
downloadopenbsd-068d43dca5fee9b33a502e81b23525c86ec9fdb9.tar.gz
openbsd-068d43dca5fee9b33a502e81b23525c86ec9fdb9.tar.bz2
openbsd-068d43dca5fee9b33a502e81b23525c86ec9fdb9.zip
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 'src/lib')
-rw-r--r--src/lib/libc/net/inet_network.c7
1 files changed, 4 insertions, 3 deletions
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 @@
32 */ 32 */
33 33
34#if defined(LIBC_SCCS) && !defined(lint) 34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: inet_network.c,v 1.5 1997/04/05 21:13:14 millert Exp $"; 35static char rcsid[] = "$OpenBSD: inet_network.c,v 1.6 1997/04/24 08:35:21 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */ 36#endif /* LIBC_SCCS and not lint */
37 37
38#include <sys/types.h> 38#include <sys/types.h>
@@ -83,9 +83,10 @@ again:
83 return (INADDR_NONE); 83 return (INADDR_NONE);
84 *pp++ = val; 84 *pp++ = val;
85 n = pp - parts; 85 n = pp - parts;
86 for (val = 0, i = 0; i < n; i++) { 86 for (val = 0, i = 0; i < 4; i++) {
87 val <<= 8; 87 val <<= 8;
88 val |= parts[i] & 0xff; 88 if (i < n)
89 val |= parts[i] & 0xff;
89 } 90 }
90 return (val); 91 return (val);
91} 92}