Re: svn commit: r1585657 - /tomcat/jk/trunk/native/common/jk_connect.c
On 04/10/2014 09:57 PM, Konstantin Kolinko wrote: 2014-04-08 11:52 GMT+04:00 : Author: mturk Date: Tue Apr 8 07:52:56 2014 New Revision: 1585657 URL: http://svn.apache.org/r1585657 Log: Use port when calling getaddrinfo and skip bogus addresses Modified: tomcat/jk/trunk/native/common/jk_connect.c Modified: tomcat/jk/trunk/native/common/jk_connect.c URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_connect.c?rev=1585657&r1=1585656&r2=1585657&view=diff == --- tomcat/jk/trunk/native/common/jk_connect.c (original) +++ tomcat/jk/trunk/native/common/jk_connect.c Tue Apr 8 07:52:56 2014 @@ -430,6 +430,8 @@ int jk_resolve(const char *host, int por */ struct addrinfo hints, *ai_list, *ai = NULL; int error; +char pbuf[12]; +char *pbufptr = NULL; memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; @@ -440,7 +442,11 @@ int jk_resolve(const char *host, int por else #endif hints.ai_family = JK_INET; -error = getaddrinfo(host, NULL, &hints, &ai_list); +if (port > 0) { +snprintf(pbuf, port, sizeof(pbuf)); +pbufptr = pbuf; +} +error = getaddrinfo(host, pbufptr, &hints, &ai_list); The "getaddrinfo" method is called twice in this method. The above modifies the first call. Apply the same change to the second call, a few lines below? Hmm, yes, good catch. Regards -- ^TM - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Re: svn commit: r1585657 - /tomcat/jk/trunk/native/common/jk_connect.c
2014-04-08 11:52 GMT+04:00 : > Author: mturk > Date: Tue Apr 8 07:52:56 2014 > New Revision: 1585657 > > URL: http://svn.apache.org/r1585657 > Log: > Use port when calling getaddrinfo and skip bogus addresses > > Modified: > tomcat/jk/trunk/native/common/jk_connect.c > > Modified: tomcat/jk/trunk/native/common/jk_connect.c > URL: > http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_connect.c?rev=1585657&r1=1585656&r2=1585657&view=diff > == > --- tomcat/jk/trunk/native/common/jk_connect.c (original) > +++ tomcat/jk/trunk/native/common/jk_connect.c Tue Apr 8 07:52:56 2014 > @@ -430,6 +430,8 @@ int jk_resolve(const char *host, int por > */ > struct addrinfo hints, *ai_list, *ai = NULL; > int error; > +char pbuf[12]; > +char *pbufptr = NULL; > > memset(&hints, 0, sizeof(hints)); > hints.ai_socktype = SOCK_STREAM; > @@ -440,7 +442,11 @@ int jk_resolve(const char *host, int por > else > #endif > hints.ai_family = JK_INET; > -error = getaddrinfo(host, NULL, &hints, &ai_list); > +if (port > 0) { > +snprintf(pbuf, port, sizeof(pbuf)); > +pbufptr = pbuf; > +} > +error = getaddrinfo(host, pbufptr, &hints, &ai_list); The "getaddrinfo" method is called twice in this method. The above modifies the first call. Apply the same change to the second call, a few lines below? Best regards, Konstantin Kolinko - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
svn commit: r1585657 - /tomcat/jk/trunk/native/common/jk_connect.c
Author: mturk Date: Tue Apr 8 07:52:56 2014 New Revision: 1585657 URL: http://svn.apache.org/r1585657 Log: Use port when calling getaddrinfo and skip bogus addresses Modified: tomcat/jk/trunk/native/common/jk_connect.c Modified: tomcat/jk/trunk/native/common/jk_connect.c URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_connect.c?rev=1585657&r1=1585656&r2=1585657&view=diff == --- tomcat/jk/trunk/native/common/jk_connect.c (original) +++ tomcat/jk/trunk/native/common/jk_connect.c Tue Apr 8 07:52:56 2014 @@ -430,6 +430,8 @@ int jk_resolve(const char *host, int por */ struct addrinfo hints, *ai_list, *ai = NULL; int error; +char pbuf[12]; +char *pbufptr = NULL; memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; @@ -440,7 +442,11 @@ int jk_resolve(const char *host, int por else #endif hints.ai_family = JK_INET; -error = getaddrinfo(host, NULL, &hints, &ai_list); +if (port > 0) { +snprintf(pbuf, port, sizeof(pbuf)); +pbufptr = pbuf; +} +error = getaddrinfo(host, pbufptr, &hints, &ai_list); #if JK_HAVE_IPV6 /* XXX: * Is the check for EAI_FAMILY/WSAEAFNOSUPPORT correct @@ -461,12 +467,13 @@ int jk_resolve(const char *host, int por ai = ai_list; while (ai) { if (ai->ai_family == AF_INET6) { -family = JK_INET6; -break; -} -else { -ai = ai->ai_next; +/* ignore elements without required address info */ +if((ai->ai_addr != NULL) && (ai->ai_addrlen > 0)) { +family = JK_INET6; +break; +} } +ai = ai->ai_next; } } #endif @@ -474,12 +481,13 @@ int jk_resolve(const char *host, int por ai = ai_list; while (ai) { if (ai->ai_family == AF_INET) { -family = JK_INET; -break; -} -else { -ai = ai->ai_next; +/* ignore elements without required address info */ +if((ai->ai_addr != NULL) && (ai->ai_addrlen > 0)) { +family = JK_INET; +break; +} } +ai = ai->ai_next; } } if (ai == NULL) { - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org