From: Daniel Stenberg Date: Fri, 4 Jan 2002 09:38:52 +0000 (+0000) Subject: an unconditional occurance of inet_ntoa() now uses inet_ntoa_r() on all X-Git-Tag: curl-7_9_3-pre1~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f75ff58b4b2ddf2181a69199f65a7d7cc55aaa52;p=thirdparty%2Fcurl.git an unconditional occurance of inet_ntoa() now uses inet_ntoa_r() on all 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... --- diff --git a/lib/url.c b/lib/url.c index 3973902efc..5f75680054 100644 --- a/lib/url.c +++ b/lib/url.c @@ -110,6 +110,10 @@ #include +#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 @@ -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