diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-07-14 22:32:29 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-07-14 22:32:29 +0000 |
commit | ed3f5d37739a662cb08285e2230a7822ecc9173d (patch) | |
tree | f8f902d38011e82daa5eb6696813e6e08940de0d /main | |
parent | 851016296bfff6fbd44631b4464d5e888105ffb2 (diff) |
Fix errors where incorrect address information was printed.
ast_sockaddr_stringiy_fmt (which is call by all ast_sockaddr_stringify* functions)
uses thread-local storage for storing the string that it creates. In cases where
ast_sockaddr_stringify_fmt was being called twice within the same statement, the
result of one call would be overwritten by the result of the other call. This
usually was happening in printf-like statements and was resulting in the same
stringified addressed being printed twice instead of two separate addresses.
I have fixed this by using ast_strdupa on the result of stringify functions if
they are used twice within the same statement. As far as I could tell, there were
no instances where a pointer to the result of such a call were saved anywhere, so
this is the only situation I could see where this error could occur.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@276570 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/acl.c | 4 | ||||
-rw-r--r-- | main/dnsmgr.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/main/acl.c b/main/acl.c index 082048a16..663c0b225 100644 --- a/main/acl.c +++ b/main/acl.c @@ -529,8 +529,8 @@ int ast_ouraddrfor(const struct ast_sockaddr *them, struct ast_sockaddr *us) } close(s); ast_debug(3, "For destination '%s', our source address is '%s'.\n", - ast_sockaddr_stringify_addr(them), - ast_sockaddr_stringify_addr(us)); + ast_strdupa(ast_sockaddr_stringify_addr(them)), + ast_strdupa(ast_sockaddr_stringify_addr(us))); ast_sockaddr_set_port(us, port); diff --git a/main/dnsmgr.c b/main/dnsmgr.c index 29ac4e30f..5818c0478 100644 --- a/main/dnsmgr.c +++ b/main/dnsmgr.c @@ -161,8 +161,8 @@ static int dnsmgr_refresh(struct ast_dnsmgr_entry *entry, int verbose) ast_sockaddr_set_port(&tmp, ast_sockaddr_port(entry->result)); if (ast_sockaddr_cmp(&tmp, entry->result)) { ast_log(LOG_NOTICE, "dnssrv: host '%s' changed from %s to %s\n", - entry->name, ast_sockaddr_stringify(entry->result), - ast_sockaddr_stringify(&tmp)); + entry->name, ast_strdupa(ast_sockaddr_stringify(entry->result)), + ast_strdupa(ast_sockaddr_stringify(&tmp))); ast_sockaddr_copy(entry->result, &tmp); changed = entry->changed = 1; |