diff options
author | Daniel Stenberg <daniel@haxx.se> | 2002-01-04 09:38:52 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2002-01-04 09:38:52 +0000 |
commit | f75ff58b4b2ddf2181a69199f65a7d7cc55aaa52 (patch) | |
tree | de32d923fc9ecdfa5527fd9b788679d986343336 /lib | |
parent | ae9bf16dee59f6a0fefdd9484d434a61ee7c601a (diff) |
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...
Diffstat (limited to 'lib')
-rw-r--r-- | lib/url.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -110,6 +110,10 @@ #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 |