Merged revisions 110336 via svnmerge from
authorRussell Bryant <russell@russellbryant.com>
Thu, 20 Mar 2008 21:55:50 +0000 (21:55 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 20 Mar 2008 21:55:50 +0000 (21:55 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r110336 | russell | 2008-03-20 16:54:58 -0500 (Thu, 20 Mar 2008) | 14 lines

Merged revisions 110335 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r110335 | russell | 2008-03-20 16:53:27 -0500 (Thu, 20 Mar 2008) | 6 lines

Fix some very broken code that was introduced in 1.2.26 as a part of the security
fix.  The dnsmgr is not appropriate here.  The dnsmgr takes a pointer to an address
structure that a background thread continuously updates.  However, in these cases,
a stack variable was passed.  That means that the dnsmgr thread would be continuously
writing to bogus memory.

........

................

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@110337 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c
channels/chan_sip.c

index 1887ec3..95f4a3c 100644 (file)
@@ -2959,10 +2959,9 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in
                if (var && sin) {
                        for (tmp = var; tmp; tmp = tmp->next) {
                                if (!strcasecmp(tmp->name, "host")) {
-                                       struct in_addr sin2;
-                                       struct ast_dnsmgr_entry *dnsmgr = NULL;
-                                       memset(&sin2, 0, sizeof(sin2));
-                                       if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
+                                       struct ast_hostent ahp;
+                                       struct hostent *hp;
+                                       if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || (memcmp(&hp->h_addr, &sin->sin_addr, sizeof(hp->h_addr)))) {
                                                /* No match */
                                                ast_variables_destroy(var);
                                                var = NULL;
@@ -3072,10 +3071,9 @@ static struct iax2_user *realtime_user(const char *username, struct sockaddr_in
                if (var) {
                        for (tmp = var; tmp; tmp = tmp->next) {
                                if (!strcasecmp(tmp->name, "host")) {
-                                       struct in_addr sin2;
-                                       struct ast_dnsmgr_entry *dnsmgr = NULL;
-                                       memset(&sin2, 0, sizeof(sin2));
-                                       if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
+                                       struct ast_hostent ahp;
+                                       struct hostent *hp;
+                                       if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || (memcmp(&hp->h_addr, &sin->sin_addr, sizeof(hp->h_addr)))) {
                                                /* No match */
                                                ast_variables_destroy(var);
                                                var = NULL;
index dbdc20f..39648d5 100644 (file)
@@ -3607,10 +3607,9 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i
                        if (var) {
                                for (tmp = var; tmp; tmp = tmp->next) {
                                        if (!strcasecmp(var->name, "host")) {
-                                               struct in_addr sin2;
-                                               struct ast_dnsmgr_entry *dnsmgr = NULL;
-                                               memset(&sin2, 0, sizeof(sin2));
-                                               if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
+                                               struct hostent *hp;
+                                               struct ast_hostent ahp;
+                                               if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || (memcmp(&hp->h_addr, &sin->sin_addr, sizeof(hp->h_addr)))) {
                                                        /* No match */
                                                        ast_variables_destroy(var);
                                                        var = NULL;