summaryrefslogtreecommitdiff
path: root/main/config.c
diff options
context:
space:
mode:
authorWalter Doekes <walter+asterisk@wjd.nu>2011-11-01 21:02:56 +0000
committerWalter Doekes <walter+asterisk@wjd.nu>2011-11-01 21:02:56 +0000
commitb41b49ea0e0ebdb7250f9d560b13f6fa21456694 (patch)
tree7bc973c1dc9f6e499c92491895b3a6d55ba825dd /main/config.c
parent25ee5f83b5c9e77be328a92b430d911396f1ac29 (diff)
Several fixes to the chan_sip dynamic realtime peer/user lookup
There were several problems with the dynamic realtime peer/user lookup code. The lookup logic had become rather hard to read due to lots of incremental changes to the realtime_peer function. And, during the addition of the sipregs functionality, several possibilities for memory leaks had been introduced. The insecure=port matching has always been broken for anyone using the sipregs family. And, related, the broken implementation forced those using sipregs to *still* have an ipaddr column on their sippeers table. Thanks Terry Wilson for comprehensive testing and finding and fixing unexpected behaviour from the multientry realtime call which caused the realtime_peer to have a completely unused code path. This changeset fixes the leaks, the lookup inconsistenties and that you won't need an ipaddr column on your sippeers table anymore (when you're using sipregs). Beware that when you're using sipregs, peers with insecure=port will now start matching! (closes issue ASTERISK-17792) (closes issue ASTERISK-18356) Reported by: marcelloceschia, Walter Doekes Reviewed by: Terry Wilson Review: https://reviewboard.asterisk.org/r/1395 ........ Merged revisions 342927 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 342929 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@342930 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/config.c')
-rw-r--r--main/config.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/main/config.c b/main/config.c
index 23d98da8a..498ae993d 100644
--- a/main/config.c
+++ b/main/config.c
@@ -525,6 +525,28 @@ static void ast_variable_destroy(struct ast_variable *doomed)
ast_free(doomed);
}
+struct ast_variable *ast_variables_dup(struct ast_variable *var)
+{
+ struct ast_variable *cloned;
+ struct ast_variable *tmp;
+
+ if (!(cloned = ast_variable_new(var->name, var->value, var->file))) {
+ return NULL;
+ }
+
+ tmp = cloned;
+
+ while ((var = var->next)) {
+ if (!(tmp->next = ast_variable_new(var->name, var->value, var->file))) {
+ ast_variables_destroy(cloned);
+ return NULL;
+ }
+ tmp = tmp->next;
+ }
+
+ return cloned;
+}
+
void ast_variables_destroy(struct ast_variable *v)
{
struct ast_variable *vn;