]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix invalid reads/writes due to incorrect sizeof().
authorRussell Bryant <russell@russellbryant.com>
Wed, 14 Mar 2012 10:05:07 +0000 (10:05 +0000)
committerRussell Bryant <russell@russellbryant.com>
Wed, 14 Mar 2012 10:05:07 +0000 (10:05 +0000)
These few places in the code used sizeof() on h_addr in struct hostent.
This is sizeof(char *).  The correct way to get the size of this address is to
use h_length.  This error would result in reads/writes of 8 bytes instead of 4
on 64-bit machines.
........

Merged revisions 359211 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 359212 from http://svn.asterisk.org/svn/asterisk/branches/10

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

apps/app_externalivr.c
channels/chan_iax2.c

index 0dee58ceaa00d6cb261870a3c096cefacd16dc02..5a320002ba6bd9136cd4a67f0ca3b9a316743db5 100644 (file)
@@ -515,7 +515,7 @@ static int app_exec(struct ast_channel *chan, const char *data)
                ast_gethostbyname(hostname, &hp);
                remote_address_tmp.sin_family = AF_INET;
                remote_address_tmp.sin_port = htons(port);
-               memcpy(&remote_address_tmp.sin_addr.s_addr, hp.hp.h_addr, sizeof(hp.hp.h_addr));
+               memcpy(&remote_address_tmp.sin_addr.s_addr, hp.hp.h_addr, hp.hp.h_length);
                ast_sockaddr_from_sin(&ivr_desc.remote_address, &remote_address_tmp);
                if (!(ser = ast_tcptls_client_create(&ivr_desc)) || !(ser = ast_tcptls_client_start(ser))) {
                        goto exit;
index 20114a2859383952c8cc73071b1192ed5b6b96b7..a3e0cb47b362205a445829bf546de4ff521f9979 100644 (file)
@@ -4354,7 +4354,7 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in
                                if (!strcasecmp(tmp->name, "host")) {
                                        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)))) {
+                                       if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || memcmp(hp->h_addr, &sin->sin_addr, hp->h_length)) {
                                                /* No match */
                                                ast_variables_destroy(var);
                                                var = NULL;
@@ -4466,7 +4466,7 @@ static struct iax2_user *realtime_user(const char *username, struct sockaddr_in
                                if (!strcasecmp(tmp->name, "host")) {
                                        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)))) {
+                                       if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || memcmp(hp->h_addr, &sin->sin_addr, hp->h_length)) {
                                                /* No match */
                                                ast_variables_destroy(var);
                                                var = NULL;