mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
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...
This commit is contained in:
parent
ae9bf16dee
commit
f75ff58b4b
14
lib/url.c
14
lib/url.c
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user