2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 06:55:30 +00:00

Fix coverity warnings in acl.c and iptable.c [rt17455]

This commit is contained in:
Evan Hunt
2008-01-17 08:08:08 +00:00
parent c6d486af36
commit 1aba9fe678
4 changed files with 26 additions and 11 deletions

View File

@@ -1,3 +1,6 @@
2309. [cleanup] Fix Coverity warnings in lib/dns/acl.c and iptable.c.
[RT #17455]
2308. [cleanup] Silence Coverity warning in bin/named/controlconf.c. 2308. [cleanup] Silence Coverity warning in bin/named/controlconf.c.
[RT #17495] [RT #17495]

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: acl.c,v 1.37 2007/12/21 06:46:47 marka Exp $ */ /* $Id: acl.c,v 1.38 2008/01/17 08:08:08 each Exp $ */
/*! \file */ /*! \file */
@@ -102,7 +102,13 @@ dns_acl_anyornone(isc_mem_t *mctx, isc_boolean_t neg, dns_acl_t **target) {
result = dns_acl_create(mctx, 0, &acl); result = dns_acl_create(mctx, 0, &acl);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
return (result); return (result);
dns_iptable_addprefix(acl->iptable, NULL, 0, ISC_TF(!neg));
result = dns_iptable_addprefix(acl->iptable, NULL, 0, ISC_TF(!neg));
if (result != ISC_R_SUCCESS) {
dns_acl_detach(&acl);
return (result);
}
*target = acl; *target = acl;
return (result); return (result);
} }

View File

@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: iptable.c,v 1.5 2007/09/28 00:11:32 each Exp $ */ /* $Id: iptable.c,v 1.6 2008/01/17 08:08:08 each Exp $ */
#include <isc/mem.h> #include <isc/mem.h>
#include <isc/radix.h> #include <isc/radix.h>
@@ -66,6 +66,7 @@ dns_iptable_addprefix(dns_iptable_t *tab, isc_netaddr_t *addr,
INSIST(DNS_IPTABLE_VALID(tab)); INSIST(DNS_IPTABLE_VALID(tab));
INSIST(tab->radix); INSIST(tab->radix);
INSIST(bitlen <= 32 || (addr->family == AF_INET6 && bitlen <= 128));
NETADDR_TO_PREFIX_T(addr, pfx, bitlen); NETADDR_TO_PREFIX_T(addr, pfx, bitlen);

View File

@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: radix.h,v 1.5 2007/09/28 00:11:32 each Exp $ */ /* $Id: radix.h,v 1.6 2008/01/17 08:08:08 each Exp $ */
/* /*
* This source was adapted from MRT's RCS Ids: * This source was adapted from MRT's RCS Ids:
@@ -36,13 +36,18 @@
#define NETADDR_TO_PREFIX_T(na,pt,bits) \ #define NETADDR_TO_PREFIX_T(na,pt,bits) \
do { \ do { \
memset(&(pt), 0, sizeof(pt)); \ memset(&(pt), 0, sizeof(pt)); \
if((bits) && (na) != NULL) { \ if((bits) && (na) != NULL) { \
memcpy(&(pt).add.sin, &(na)->type.in, ((bits)+7)/8); \ (pt).family = (na)->family; \
(pt).bitlen = (bits); \ (pt).bitlen = (bits); \
(pt).family = (na)->family; \ if ((pt).family == AF_INET6) { \
} else \ memcpy(&(pt).add.sin6, &(na)->type.in6, \
(pt).family = AF_INET; \ ((bits)+7)/8); \
} else \
memcpy(&(pt).add.sin, &(na)->type.in, \
((bits)+7)/8); \
} else \
(pt).family = AF_INET; \
isc_refcount_init(&(pt).refcount, 0); \ isc_refcount_init(&(pt).refcount, 0); \
} while(0) } while(0)