summaryrefslogtreecommitdiff
path: root/main/acl.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2010-02-25 22:41:48 +0000
committerMark Michelson <mmichelson@digium.com>2010-02-25 22:41:48 +0000
commita1af5f4f726f8878a403577abf067709b8357db3 (patch)
tree8888fa66a451a4e13066eb40ff9f4c227970cc53 /main/acl.c
parenta0af2cff0ec70f504c7723f3d134533d9bc6f435 (diff)
Fix incorrect ACL behavior when CIDR notation of "/0" is used.
AST-2010-003 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@248946 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/acl.c')
-rw-r--r--main/acl.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/main/acl.c b/main/acl.c
index 3c01fb65b..67c05b03c 100644
--- a/main/acl.c
+++ b/main/acl.c
@@ -298,7 +298,14 @@ struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha
if (!strchr(nm, '.')) {
if ((sscanf(nm, "%30d", &x) == 1) && (x >= 0) && (x <= 32)) {
- ha->netmask.s_addr = htonl(0xFFFFFFFF << (32 - x));
+ if (x == 0) {
+ /* This is special-cased to prevent unpredictable
+ * behavior of shifting left 32 bits
+ */
+ ha->netmask.s_addr = 0;
+ } else {
+ ha->netmask.s_addr = htonl(0xFFFFFFFF << (32 - x));
+ }
} else {
ast_log(LOG_WARNING, "Invalid CIDR in %s\n", stuff);
ast_free(ha);