]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Issue#7530 - Test for ERANGE when using 6 form gethostbyname_r
authorQuanah Gibson-Mount <quanah@openldap.org>
Fri, 22 May 2020 23:45:40 +0000 (23:45 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Tue, 26 May 2020 19:18:02 +0000 (19:18 +0000)
libraries/libldap/util-int.c

index 50c802727f2bde8f11f4b8d407f3c07d96f8baba..b2c76defa320eeae8d1cc3537ab5302ad0537553 100644 (file)
@@ -445,8 +445,12 @@ int ldap_pvt_gethostbyname_a(
                *result=gethostbyname_r( name, resbuf, *buf, buflen, herrno_ptr );
                r = (*result == NULL) ?  -1 : 0;
 #else
-               r = gethostbyname_r( name, resbuf, *buf,
-                       buflen, result, herrno_ptr );
+               while((r = gethostbyname_r( name, resbuf, *buf, buflen, result, herrno_ptr )) == ERANGE) {
+                       /* Increase the buffer */
+                       buflen*=2;
+                       if (safe_realloc(buf, buflen) == NULL)
+                               return -1;
+               }
 #endif
 
                Debug2( LDAP_DEBUG_TRACE, "ldap_pvt_gethostbyname_a: host=%s, r=%d\n",