diff options
author | 1997-04-24 08:35:21 +0000 | |
---|---|---|
committer | 1997-04-24 08:35:21 +0000 | |
commit | 5dbce1d97deebbaba04badbf3ff7c6641e4db889 (patch) | |
tree | 59118c608f0fb799ecf194d2cd0a1cd586452541 /lib/libc/net/inet_network.c | |
parent | Enforce read only mounts. No exceptions. (diff) | |
download | wireguard-openbsd-5dbce1d97deebbaba04badbf3ff7c6641e4db889.tar.xz wireguard-openbsd-5dbce1d97deebbaba04badbf3ff7c6641e4db889.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 'lib/libc/net/inet_network.c')
-rw-r--r-- | lib/libc/net/inet_network.c | 7 |
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); } |