Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libwrap don't use inet_addr, use inet_aton... Otherwise ...



details:   https://anonhg.NetBSD.org/src/rev/a95e65d2ee85
branches:  trunk
changeset: 472829:a95e65d2ee85
user:      christos <christos%NetBSD.org@localhost>
date:      Sun May 09 16:03:10 1999 +0000

description:
don't use inet_addr, use inet_aton... Otherwise masks of 255.255.255.255
don't work, so we cannot restrict rules to a single host.

diffstat:

 lib/libwrap/hosts_access.c |  12 ++++++------
 lib/libwrap/misc.c         |  27 +++++++++------------------
 lib/libwrap/tcpd.h         |   6 +++---
 3 files changed, 18 insertions(+), 27 deletions(-)

diffs (110 lines):

diff -r ff99c9d41722 -r a95e65d2ee85 lib/libwrap/hosts_access.c
--- a/lib/libwrap/hosts_access.c        Sun May 09 15:10:30 1999 +0000
+++ b/lib/libwrap/hosts_access.c        Sun May 09 16:03:10 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hosts_access.c,v 1.5 1999/01/18 20:21:19 christos Exp $        */
+/*     $NetBSD: hosts_access.c,v 1.6 1999/05/09 16:03:10 christos Exp $        */
 
  /*
   * This module implements a simple access control language that is based on
@@ -24,7 +24,7 @@
 #if 0
 static char sccsid[] = "@(#) hosts_access.c 1.20 96/02/11 17:01:27";
 #else
-__RCSID("$NetBSD: hosts_access.c,v 1.5 1999/01/18 20:21:19 christos Exp $");
+__RCSID("$NetBSD: hosts_access.c,v 1.6 1999/05/09 16:03:10 christos Exp $");
 #endif
 #endif
 
@@ -307,7 +307,7 @@
     int ret = NO;
     size_t len = strlen(rbl_domain) + (4 * 4) + 2;
  
-    if ((host_address = dot_quad_addr(rbl_hostaddr)) == INADDR_NONE) {
+    if (dot_quad_addr(rbl_hostaddr, &host_address) != 0) {
        tcpd_warn("unable to convert %s to address", rbl_hostaddr);
        return (NO);
     }
@@ -371,10 +371,10 @@
      * access control language. John P. Rouillard <rouilj%cs.umb.edu@localhost>.
      */
 
-    if ((addr = dot_quad_addr(string)) == INADDR_NONE)
+    if (dot_quad_addr(string, &addr) != 0)
        return (NO);
-    if ((net = dot_quad_addr(net_tok)) == INADDR_NONE
-       || (mask = dot_quad_addr(mask_tok)) == INADDR_NONE) {
+    if (dot_quad_addr(net_tok, &net) != 0
+       || dot_quad_addr(mask_tok, &mask) != 0) {
        tcpd_warn("bad net/mask expression: %s/%s", net_tok, mask_tok);
        return (NO);                            /* not tcpd_jump() */
     }
diff -r ff99c9d41722 -r a95e65d2ee85 lib/libwrap/misc.c
--- a/lib/libwrap/misc.c        Sun May 09 15:10:30 1999 +0000
+++ b/lib/libwrap/misc.c        Sun May 09 16:03:10 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: misc.c,v 1.2 1997/10/09 21:20:35 christos Exp $        */
+/*     $NetBSD: misc.c,v 1.3 1999/05/09 16:03:11 christos Exp $        */
 
  /*
   * Misc routines that are used by tcpd and by tcpdchk.
@@ -11,7 +11,7 @@
 #if 0
 static char sccsic[] = "@(#) misc.c 1.2 96/02/11 17:01:29";
 #else
-__RCSID("$NetBSD: misc.c,v 1.2 1997/10/09 21:20:35 christos Exp $");
+__RCSID("$NetBSD: misc.c,v 1.3 1999/05/09 16:03:11 christos Exp $");
 #endif
 #endif
 
@@ -70,23 +70,14 @@
 
 /* dot_quad_addr - convert dotted quad to internal form */
 
-unsigned long dot_quad_addr(str)
+int dot_quad_addr(str, addr)
 char   *str;
+unsigned long *addr;
 {
-    int     in_run = 0;
-    int     runs = 0;
-    char   *cp = str;
-
-    /* Count the number of runs of non-dot characters. */
+    struct in_addr a;
 
-    while (*cp) {
-       if (*cp == '.') {
-           in_run = 0;
-       } else if (in_run == 0) {
-           in_run = 1;
-           runs++;
-       }
-       cp++;
-    }
-    return (runs == 4 ? inet_addr(str) : INADDR_NONE);
+    if (!inet_aton(str, &a))
+       return -1;
+    *addr = a.s_addr;
+    return 0;
 }
diff -r ff99c9d41722 -r a95e65d2ee85 lib/libwrap/tcpd.h
--- a/lib/libwrap/tcpd.h        Sun May 09 15:10:30 1999 +0000
+++ b/lib/libwrap/tcpd.h        Sun May 09 16:03:10 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcpd.h,v 1.4 1999/01/18 19:54:20 christos Exp $        */
+/*     $NetBSD: tcpd.h,v 1.5 1999/05/09 16:03:11 christos Exp $        */
  /*
   * @(#) tcpd.h 1.5 96/03/19 16:22:24
   * 
@@ -90,8 +90,8 @@
                __P((char *, int, FILE *));
 extern char *split_at                  /* strchr() and split */
                __P((char *, int));
-extern unsigned long dot_quad_addr     /* restricted inet_addr() */
-               __P((char *));
+extern int dot_quad_addr       /* restricted inet_aton() */
+               __P((char *, unsigned long *));
 
 /* Global variables. */
 



Home | Main Index | Thread Index | Old Index