whitespace fixes
This commit is contained in:
parent
6e216b19f0
commit
b19bc49769
@ -40,7 +40,7 @@
|
|||||||
*/
|
*/
|
||||||
struct acl_s {
|
struct acl_s {
|
||||||
acl_access_t access;
|
acl_access_t access;
|
||||||
struct hostspec h;
|
struct hostspec h;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -85,8 +85,8 @@ insert_acl (char *location, acl_access_t access_type, acl_list_t *access_list)
|
|||||||
*/
|
*/
|
||||||
memset (&acl, 0, sizeof (struct acl_s));
|
memset (&acl, 0, sizeof (struct acl_s));
|
||||||
acl.access = access_type;
|
acl.access = access_type;
|
||||||
if(hostspec_parse(location, &acl.h) || acl.h.type == HST_NONE)
|
if(hostspec_parse(location, &acl.h) || acl.h.type == HST_NONE)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if(!sblist_add(*access_list, &acl)) return -1;
|
if(!sblist_add(*access_list, &acl)) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
@ -249,6 +249,7 @@ int check_acl (const char *ip, union sockaddr_union *addr, acl_list_t access_lis
|
|||||||
? check_numeric_acl (acl, numeric_addr)
|
? check_numeric_acl (acl, numeric_addr)
|
||||||
: -1;
|
: -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HST_NONE:
|
case HST_NONE:
|
||||||
perm = -1;
|
perm = -1;
|
||||||
break;
|
break;
|
||||||
|
@ -13,45 +13,45 @@
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
fill_netmask_array (char *bitmask_string, int v6,
|
fill_netmask_array (char *bitmask_string, int v6,
|
||||||
unsigned char array[], size_t len)
|
unsigned char array[], size_t len)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned long int mask;
|
unsigned long int mask;
|
||||||
char *endptr;
|
char *endptr;
|
||||||
|
|
||||||
errno = 0; /* to distinguish success/failure after call */
|
errno = 0; /* to distinguish success/failure after call */
|
||||||
mask = strtoul (bitmask_string, &endptr, 10);
|
mask = strtoul (bitmask_string, &endptr, 10);
|
||||||
|
|
||||||
/* check for various conversion errors */
|
/* check for various conversion errors */
|
||||||
if ((errno == ERANGE && mask == ULONG_MAX)
|
if ((errno == ERANGE && mask == ULONG_MAX)
|
||||||
|| (errno != 0 && mask == 0) || (endptr == bitmask_string))
|
|| (errno != 0 && mask == 0) || (endptr == bitmask_string))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (v6 == 0) {
|
if (v6 == 0) {
|
||||||
/* The mask comparison is done as an IPv6 address, so
|
/* The mask comparison is done as an IPv6 address, so
|
||||||
* convert to a longer mask in the case of IPv4
|
* convert to a longer mask in the case of IPv4
|
||||||
* addresses. */
|
* addresses. */
|
||||||
mask += 12 * 8;
|
mask += 12 * 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check valid range for a bit mask */
|
/* check valid range for a bit mask */
|
||||||
if (mask > (8 * len))
|
if (mask > (8 * len))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* we have a valid range to fill in the array */
|
/* we have a valid range to fill in the array */
|
||||||
for (i = 0; i != len; ++i) {
|
for (i = 0; i != len; ++i) {
|
||||||
if (mask >= 8) {
|
if (mask >= 8) {
|
||||||
array[i] = 0xff;
|
array[i] = 0xff;
|
||||||
mask -= 8;
|
mask -= 8;
|
||||||
} else if (mask > 0) {
|
} else if (mask > 0) {
|
||||||
array[i] = (unsigned char) (0xff << (8 - mask));
|
array[i] = (unsigned char) (0xff << (8 - mask));
|
||||||
mask = 0;
|
mask = 0;
|
||||||
} else {
|
} else {
|
||||||
array[i] = 0;
|
array[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ int hostspec_parse(char *location, struct hostspec *h) {
|
|||||||
for (i = 0; i < IPV6_LEN; i++)
|
for (i = 0; i < IPV6_LEN; i++)
|
||||||
h->address.ip.network[i] = ip_dst[i] &
|
h->address.ip.network[i] = ip_dst[i] &
|
||||||
h->address.ip.mask[i];
|
h->address.ip.mask[i];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* either bogus IP or hostname */
|
/* either bogus IP or hostname */
|
||||||
/* bogus ipv6 ? */
|
/* bogus ipv6 ? */
|
||||||
@ -141,7 +141,7 @@ static int numeric_match(const uint8_t addr[], const struct hostspec *h)
|
|||||||
/* If x and y don't match, the IP addresses don't match */
|
/* If x and y don't match, the IP addresses don't match */
|
||||||
if (x != y)
|
if (x != y)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user