[PATCH] gethostbyname segfault

"Vincent CHAVANIS" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <068901c6387c$505f97a0$9600a8c0@vince>
This fixes the segfault i had,

when tried to connect bearbox on X86_64SMP and DNS SERVERS IPV6 compatible.
gethostbyname2() works like gethostbyname(), but permits to specify the address family (AF_INET) to which the address must belong.
Glibc2 also has reentrant versions gethostbyname_r() and gethostbyname2_r().


--- /cvs/gateway/gwlib/protected.c 2005-02-11 16:35:48.000000000 +0100
+++ /gateway/gwlib/protected.c 2006-02-23 14:00:23.000000000 +0100
@@ -193,7 +193,7 @@
 
     bufflen = 1024;
     *buff = (char*) gw_malloc(bufflen);
-    while ((res=gethostbyname_r(name, &hp,*buff, bufflen, &tmphp, &herr)) == ERANGE) {
+    while ((res=gethostbyname2_r(name, AF_INET,&hp,*buff, bufflen, &tmphp, &herr)) == ERANGE) {
         /* enlarge the buffer */
        bufflen *= 2;
        *buff = (char*) gw_realloc(*buff, bufflen);


--
Telemaque - NICE - (FR)
Service Technique - Developpement
http://www.telemaque.fr/
[email protected]
Tel : +33 4 93 97 71 64 (fax 68)
x86_64_gehostbyname.patch.txt (text/plain, 521 B)
--- /cvs/gateway/gwlib/protected.c       2005-02-11 16:35:48.000000000 +0100
+++ /gateway/gwlib/protected.c 2006-02-23 14:00:23.000000000 +0100
@@ -193,7 +193,7 @@
 
     bufflen = 1024;
     *buff = (char*) gw_malloc(bufflen);
-    while ((res=gethostbyname_r(name, &hp,*buff, bufflen, &tmphp, &herr)) == ERANGE) {
+    while ((res=gethostbyname2_r(name, AF_INET,&hp,*buff, bufflen, &tmphp, &herr)) == ERANGE) {
         /* enlarge the buffer */
        bufflen *= 2;
        *buff = (char*) gw_realloc(*buff, bufflen);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.