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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@342927 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Walter Doekes
2011-11-01 20:53:37 +00:00
parent 68b523463d
commit ab2dacb555
4 changed files with 261 additions and 152 deletions

View File

@@ -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;