aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-02-25 19:41:12 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-02-25 19:41:12 +0000
commitd3e716a7bd794bff76b6e8a59e66f97e7391dd38 (patch)
tree2290a0c6be24752e51aa6ccdfb0530ce942092e3
parent579991fd03b87de6dc2671cb7d5179f9d646cea3 (diff)
Fix error where "/0" CIDR notation could be unpredictable.
AST-2010-003 git-svn-id: http://svn.digium.com/svn/asterisk/tags/1.6.1.17@248848 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--main/acl.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/main/acl.c b/main/acl.c
index 7a431036e..2d70c63b3 100644
--- a/main/acl.c
+++ b/main/acl.c
@@ -292,7 +292,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);