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.
This commit is contained in:
parent
69e451c1ce
commit
8c92070a91
|
@ -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 @@ char *rbl_hostaddr; /* hostaddr */
|
|||
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 @@ char *string;
|
|||
* access control language. John P. Rouillard <rouilj@cs.umb.edu>.
|
||||
*/
|
||||
|
||||
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() */
|
||||
}
|
||||
|
|
|
@ -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 @@ int delimiter;
|
|||
|
||||
/* 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;
|
||||
struct in_addr a;
|
||||
|
||||
/* Count the number of runs of non-dot characters. */
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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 @@ extern char *xgets /* fgets() on steroids */
|
|||
__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. */
|
||||
|
||||
|
|
Loading…
Reference in New Issue