diff options
-rw-r--r-- | lib/libwrap/hosts_access.c | 10 | ||||
-rw-r--r-- | lib/libwrap/misc.c | 40 | ||||
-rw-r--r-- | lib/libwrap/shlib_version | 2 | ||||
-rw-r--r-- | lib/libwrap/tcpd.h | 3 |
4 files changed, 37 insertions, 18 deletions
diff --git a/lib/libwrap/hosts_access.c b/lib/libwrap/hosts_access.c index 83aa4b05691..cde5c7feb9f 100644 --- a/lib/libwrap/hosts_access.c +++ b/lib/libwrap/hosts_access.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hosts_access.c,v 1.3 1997/06/30 06:05:59 deraadt Exp $ */ +/* $OpenBSD: hosts_access.c,v 1.4 1999/06/06 15:34:44 deraadt Exp $ */ /* * This module implements a simple access control language that is based on @@ -23,7 +23,7 @@ #if 0 static char sccsid[] = "@(#) hosts_access.c 1.21 97/02/12 02:13:22"; #else -static char rcsid[] = "$OpenBSD: hosts_access.c,v 1.3 1997/06/30 06:05:59 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: hosts_access.c,v 1.4 1999/06/06 15:34:44 deraadt Exp $"; #endif #endif @@ -328,10 +328,10 @@ char *string; * access control language. John P. Rouillard <rouilj@cs.umb.edu>. */ - if ((addr = dot_quad_addr(string)) == INADDR_NONE) + if (!dot_quad_addr_new(string, &addr)) return (NO); - if ((net = dot_quad_addr(net_tok)) == INADDR_NONE - || (mask = dot_quad_addr(mask_tok)) == INADDR_NONE) { + if (!dot_quad_addr_new(net_tok, &net) || + !dot_quad_addr_new(mask_tok, &mask)) { tcpd_warn("bad net/mask expression: %s/%s", net_tok, mask_tok); return (NO); /* not tcpd_jump() */ } 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; } diff --git a/lib/libwrap/shlib_version b/lib/libwrap/shlib_version index 1edea46de91..893819d18ff 100644 --- a/lib/libwrap/shlib_version +++ b/lib/libwrap/shlib_version @@ -1,2 +1,2 @@ major=1 -minor=0 +minor=1 diff --git a/lib/libwrap/tcpd.h b/lib/libwrap/tcpd.h index 721b2a92bd5..cbb7cf85660 100644 --- a/lib/libwrap/tcpd.h +++ b/lib/libwrap/tcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcpd.h,v 1.5 1999/04/26 04:11:02 downsj Exp $ */ +/* $OpenBSD: tcpd.h,v 1.6 1999/06/06 15:34:45 deraadt Exp $ */ /* * Copyright (c) 1997, Jason Downs. All rights reserved. @@ -114,6 +114,7 @@ extern void refuse __P((struct request_info *)); extern char *xgets __P((char *, int, FILE *)); #endif /* _STDIO_H_ */ extern char *split_at __P((char *, int)); +extern int dot_quad_addr_new __P((char *, in_addr_t *)); extern in_addr_t dot_quad_addr __P((char *)); /* Global variables. */ |