diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-06-06 15:34:46 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-06-06 15:34:46 +0000 |
commit | c984e0aca85a96a37b4fede1fbb6d8f697bdd207 (patch) | |
tree | 1d0dd5779965d156a301d2ed61d541fcb4ed6571 /lib/libwrap/misc.c | |
parent | ea1be3949f792c8eca50f8cd1078aaa59f1c857f (diff) |
add dot_quad_addr_new(); which can handle 255.255.255.255 addresses
Diffstat (limited to 'lib/libwrap/misc.c')
-rw-r--r-- | lib/libwrap/misc.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/lib/libwrap/misc.c b/lib/libwrap/misc.c index dfbb1996e3a..69e7ac1c086 100644 --- a/lib/libwrap/misc.c +++ b/lib/libwrap/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.2 1997/06/30 06:06:00 deraadt Exp $ */ +/* $OpenBSD: misc.c,v 1.3 1999/06/06 15:34:44 deraadt Exp $ */ /* * Misc routines that are used by tcpd and by tcpdchk. @@ -10,7 +10,7 @@ #if 0 static char sccsic[] = "@(#) misc.c 1.2 96/02/11 17:01:29"; #else -static char rcsid[] = "$OpenBSD: misc.c,v 1.2 1997/06/30 06:06:00 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: misc.c,v 1.3 1999/06/06 15:34:44 deraadt Exp $"; #endif #endif @@ -67,16 +67,16 @@ int delimiter; return (cp); } -/* dot_quad_addr - convert dotted quad to internal form */ - -in_addr_t dot_quad_addr(str) +/* dot_quad_addr_new - convert dotted quad to internal form */ +int +dot_quad_addr_new(str, ap) char *str; +in_addr_t *ap; { - int in_run = 0; - int runs = 0; - char *cp = str; - - /* Count the number of runs of non-dot characters. */ + struct in_addr a; + int in_run = 0; + int runs = 0; + char *cp = str; while (*cp) { if (*cp == '.') { @@ -87,5 +87,23 @@ char *str; } cp++; } - return (runs == 4 ? inet_addr(str) : INADDR_NONE); + if (runs != 4) + return 0; + + if (!inet_aton(str, &a)) + return 0; + if (ap) + *ap = a.s_addr; + return 1; +} + +/* dot_quad_addr - convert dotted quad to internal form */ +in_addr_t +dot_quad_addr(str) +char *str; +{ + in_addr_t addr; + + (void) dot_quad_addr_new(str, &addr); + return addr; } |