]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
an unconditional occurance of inet_ntoa() now uses inet_ntoa_r() on all
authorDaniel Stenberg <daniel@haxx.se>
Fri, 4 Jan 2002 09:38:52 +0000 (09:38 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 4 Jan 2002 09:38:52 +0000 (09:38 +0000)
platforms that have such a function.
This affects multi-thread running libcurls on IPv4 systems that have VERBOSE
switched on. The previous version was risking that another thread overwrote
the data before it was read out in this thread. There could possibly also
be a slight risk that the data isn't zero terminated for a short while and
thus could cause the thread to crash...

lib/url.c

index 3973902efc59b001cc00c887696582ed419f1bc9..5f75680054c5ed4de5e4286ddf390a0e2844742e 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
 
 #include <curl/types.h>
 
+#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL)
+#include "inet_ntoa_r.h"
+#endif
+
 #define _MPRINTF_REPLACE /* use our functions only */
 #include <curl/mprintf.h>
 
@@ -1224,6 +1228,9 @@ static CURLcode CreateConnection(struct SessionHandle *data,
   struct connectdata *conn_temp;
   char endbracket;
   int urllen;
+#ifdef HAVE_INET_NTOA_R
+  char ntoa_buf[64];
+#endif
 #ifdef HAVE_ALARM
   unsigned int prev_alarm;
 #endif
@@ -2214,7 +2221,12 @@ static CURLcode CreateConnection(struct SessionHandle *data,
     struct in_addr in;
     (void) memcpy(&in.s_addr, &conn->serv_addr.sin_addr, sizeof (in.s_addr));
     infof(data, "Connected to %s (%s)\n", conn->hostaddr->h_name,
-          inet_ntoa(in));
+#if defined(HAVE_INET_NTOA_R)
+          inet_ntoa_r(in, ntoa_buf, sizeof(ntoa_buf))
+#else
+          inet_ntoa(in)
+#endif
+          );
   }
 #endif