diff options
author | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-09-03 18:32:32 +0000 |
---|---|---|
committer | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-09-03 18:32:32 +0000 |
commit | 06075d395bfe1e7141986fe6387eefef5a76cb56 (patch) | |
tree | 7c14f167d74b6a5759b0caf85b652004a7c1363a /main | |
parent | 994fc0a8e68e99dbc8a8b0b3d9693b676861443d (diff) |
Merge code associated with AST-2009-006
(closes issue #12912)
Reported by: rathaus
Tested by: tilghman, russell, dvossel, dbrooks
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@216000 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/acl.c | 12 | ||||
-rw-r--r-- | main/astobj2.c | 19 |
2 files changed, 18 insertions, 13 deletions
diff --git a/main/acl.c b/main/acl.c index 8f388a3d7..2cfccf1d3 100644 --- a/main/acl.c +++ b/main/acl.c @@ -72,14 +72,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/lock.h" #include "asterisk/srv.h" -struct ast_ha { - /* Host access rule */ - struct in_addr netaddr; - struct in_addr netmask; - int sense; - struct ast_ha *next; -}; - /* Default IP - if not otherwise set, don't breathe garbage */ static struct in_addr __ourip = { .s_addr = 0x00000000, }; @@ -261,7 +253,7 @@ void ast_free_ha(struct ast_ha *ha) } /* Copy HA structure */ -static void ast_copy_ha(struct ast_ha *from, struct ast_ha *to) +void ast_copy_ha(const struct ast_ha *from, struct ast_ha *to) { memcpy(&to->netaddr, &from->netaddr, sizeof(from->netaddr)); memcpy(&to->netmask, &from->netmask, sizeof(from->netmask)); @@ -303,7 +295,7 @@ struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original) return ret; /* Return start of list */ } -struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path) +struct ast_ha *ast_append_ha(char *sense, const char *stuff, struct ast_ha *path) { struct ast_ha *ha; char *nm = "255.255.255.255"; diff --git a/main/astobj2.c b/main/astobj2.c index 8157c78cf..991fd80fe 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -453,7 +453,7 @@ void *ao2_callback(struct ao2_container *c, const enum search_flags flags, ao2_callback_fn cb_fn, void *arg) { - int i, last; /* search boundaries */ + int i, start, last; /* search boundaries */ void *ret = NULL; if (INTERNAL_OBJ(c) == NULL) /* safety check on the argument */ @@ -483,13 +483,15 @@ void *ao2_callback(struct ao2_container *c, * (this only for the time being. We need to optimize this.) */ if ((flags & OBJ_POINTER)) /* we know hash can handle this case */ - i = c->hash_fn(arg, flags & OBJ_POINTER) % c->n_buckets; + start = i = c->hash_fn(arg, flags & OBJ_POINTER) % c->n_buckets; else /* don't know, let's scan all buckets */ i = -1; /* XXX this must be fixed later. */ /* determine the search boundaries: i..last-1 */ if (i < 0) { - i = 0; + start = i = 0; + last = c->n_buckets; + } else if ((flags & OBJ_CONTINUE)) { last = c->n_buckets; } else { last = i + 1; @@ -545,6 +547,17 @@ void *ao2_callback(struct ao2_container *c, } } AST_LIST_TRAVERSE_SAFE_END + + if (ret) { + /* This assumes OBJ_MULTIPLE with !OBJ_NODATA is still not implemented */ + break; + } + + if (i == c->n_buckets - 1 && (flags & OBJ_POINTER) && (flags & OBJ_CONTINUE)) { + /* Move to the beginning to ensure we check every bucket */ + i = -1; + last = start; + } } ao2_unlock(c); return ret; |