]> andersk Git - test.git/blobdiff - libhttp/ssl.c
Fixed a NULL pointer dereference that can occur when hostnames
[test.git] / libhttp / ssl.c
index 64f2158cad6defaec06f5848dcaf53eaffbc45f1..987a990feead0d29f8a2dc626e3455aafb0df31c 100644 (file)
@@ -611,7 +611,7 @@ static int sslSNICallback(SSL *sslHndl, int *al, struct SSLSupport *ssl) {
 }
 #endif
 
-#if defined(HAVE_OPENSSL)
+#if defined(HAVE_OPENSSL) && !defined(HAVE_GETHOSTBYNAME_R)
 // This is a not-thread-safe replacement for gethostbyname_r()
 #define gethostbyname_r x_gethostbyname_r
 static int gethostbyname_r(const char *name, struct hostent *ret,
@@ -629,14 +629,16 @@ static int gethostbyname_r(const char *name, struct hostent *ret,
     return -1;
   }
   struct hostent *he = gethostbyname(name);
-  *ret               = *he;
-  if (result) {
-    *result          = ret;
+  if (he) {
+    *ret             = *he;
+    if (result) {
+      *result        = ret;
+    }
   }
   if (h_errnop) {
     *h_errnop        = h_errno;
   }
-  return 0;
+  return he ? 0 : -1;
 }
 #endif
 
This page took 0.026756 seconds and 4 git commands to generate.