projects
/
paraslash.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'refs/heads/t/mixer-fix'
[paraslash.git]
/
acl.c
diff --git
a/acl.c
b/acl.c
index 62677711e34f7c00e732bb049c705d08a9a3b8e1..2c90052658eda947ea586a55f292dc85f24e68f7 100644
(file)
--- a/
acl.c
+++ b/
acl.c
@@
-1,8
+1,4
@@
-/*
- * Copyright (C) 2005 Andre Noll <maan@tuebingen.mpg.de>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
+/* Copyright (C) 2005 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
/** \file acl.c Access control lists for paraslash senders. */
/** \file acl.c Access control lists for paraslash senders. */
@@
-35,10
+31,12
@@
struct access_info {
/**
* Return true if addr_1 matches addr_2 in the first `netmask' bits.
*/
/**
* Return true if addr_1 matches addr_2 in the first `netmask' bits.
*/
-static
int
v4_addr_match(uint32_t addr_1, uint32_t addr_2, uint8_t netmask)
+static
bool
v4_addr_match(uint32_t addr_1, uint32_t addr_2, uint8_t netmask)
{
uint32_t mask = ~0U;
{
uint32_t mask = ~0U;
+ if (netmask == 0) /* avoid 32-bit shift, which is undefined in C. */
+ return true;
if (netmask < 32)
mask <<= (32 - netmask);
return (htonl(addr_1) & mask) == (htonl(addr_2) & mask);
if (netmask < 32)
mask <<= (32 - netmask);
return (htonl(addr_1) & mask) == (htonl(addr_2) & mask);
@@
-103,14
+101,18
@@
static void acl_del_entry(struct list_head *acl, char *addr, unsigned netmask)
struct access_info *ai, *tmp;
struct in_addr to_delete;
struct access_info *ai, *tmp;
struct in_addr to_delete;
+ PARA_NOTICE_LOG("removing entries matching %s/%u\n", addr, netmask);
inet_pton(AF_INET, addr, &to_delete);
list_for_each_entry_safe(ai, tmp, acl, node) {
inet_pton(AF_INET, addr, &to_delete);
list_for_each_entry_safe(ai, tmp, acl, node) {
-
if (v4_addr_match(to_delete.s_addr, ai->addr.s_addr,
PARA_MIN(netmask, ai->netmask))) {
if (v4_addr_match(to_delete.s_addr, ai->addr.s_addr,
PARA_MIN(netmask, ai->netmask))) {
- PARA_NOTICE_LOG("removing %s/%u from access list\n",
- addr, ai->netmask);
+ char dst[INET_ADDRSTRLEN + 1];
+ const char *p = inet_ntop(AF_INET, &ai->addr.s_addr,
+ dst, sizeof(dst));
+ if (p)
+ PARA_INFO_LOG("removing %s/%u\n", p,
+ ai->netmask);
list_del(&ai->node);
free(ai);
}
list_del(&ai->node);
free(ai);
}