aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-23 01:30:42 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-23 01:30:42 +0000
commitc4b5c7fab0eccf47a6d176cf66b3fe445a3e9d66 (patch)
treed0a540d088a0ee1bb6d93de76630d8ee62037fca
parent24b57601b887adf173ca01f2f13493cb8f6aafeb (diff)
Fix for fix for security fix (third time's the charm?)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@94661 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_sip.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 58b6aef6c..45a1dfa95 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1693,7 +1693,7 @@ static void update_peer(struct sip_peer *p, int expiry)
static struct sip_peer *realtime_peer(const char *peername, struct sockaddr_in *sin)
{
struct sip_peer *peer=NULL;
- struct ast_variable *var;
+ struct ast_variable *var = NULL;
struct ast_variable *tmp;
char *newpeername = (char *) peername;
char iabuf[80];
@@ -1701,40 +1701,39 @@ static struct sip_peer *realtime_peer(const char *peername, struct sockaddr_in *
/* First check on peer name */
if (newpeername) {
var = ast_load_realtime("sippeers", "name", newpeername, "host", "dynamic", NULL);
- if (!var && sin) {
+ if (!var && sin)
var = ast_load_realtime("sippeers", "name", newpeername, "host", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), NULL);
- if (!var) {
- var = ast_load_realtime("sippeers", "name", newpeername, NULL);
- /*!\note
- * If this one loaded something, then we need to ensure that the host
- * field matched. The only reason why we can't have this as a criteria
- * is because we only have the IP address and the host field might be
- * set as a name (and the reverse PTR might not match).
- */
- if (var) {
- for (tmp = var; tmp; tmp = tmp->next) {
- if (!strcasecmp(var->name, "host")) {
- struct in_addr sin2 = { 0, };
- struct ast_dnsmgr_entry *dnsmgr = NULL;
- if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
- /* No match */
- ast_variables_destroy(var);
- var = NULL;
- }
- break;
+ if (!var) {
+ var = ast_load_realtime("sippeers", "name", newpeername, NULL);
+ /*!\note
+ * If this one loaded something, then we need to ensure that the host
+ * field matched. The only reason why we can't have this as a criteria
+ * is because we only have the IP address and the host field might be
+ * set as a name (and the reverse PTR might not match).
+ */
+ if (var) {
+ for (tmp = var; tmp; tmp = tmp->next) {
+ if (!strcasecmp(var->name, "host")) {
+ struct in_addr sin2 = { 0, };
+ struct ast_dnsmgr_entry *dnsmgr = NULL;
+ if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
+ /* No match */
+ ast_variables_destroy(var);
+ var = NULL;
}
+ break;
}
}
}
}
- } else if (sin) { /* Then check on IP address */
+ }
+
+ if (!var && sin) { /* Then check on IP address */
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr);
var = ast_load_realtime("sippeers", "host", iabuf, NULL); /* First check for fixed IP hosts */
if (!var)
var = ast_load_realtime("sippeers", "ipaddr", iabuf, NULL); /* Then check for registred hosts */
-
- } else
- return NULL;
+ }
if (!var)
return NULL;