Module: wine Branch: master Commit: c66c14ddda242cee69e8a730310c1855dc85a445 URL: http://source.winehq.org/git/wine.git/?a=commit;h=c66c14ddda242cee69e8a73031...
Author: Dmitry Timoshkov dmitry@baikal.ru Date: Wed Dec 11 17:05:01 2013 +0900
ws2_32: Move the buffer used by inet_ntoa into the per-thread data.
---
dlls/ws2_32/socket.c | 12 ++++-------- dlls/ws2_32/tests/sock.c | 1 - 2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index ee64d45..cafe103 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -378,6 +378,7 @@ struct per_thread_data int he_len; int se_len; int pe_len; + char ntoa_buffer[16]; /* 4*3 digits + 3 '.' + 1 '\0' */ };
/* internal: routing description information */ @@ -3525,17 +3526,12 @@ WS_u_short WINAPI WS_ntohs(WS_u_short netshort) */ char* WINAPI WS_inet_ntoa(struct WS_in_addr in) { - /* use "buffer for dummies" here because some applications have a - * propensity to decode addresses in ws_hostent structure without - * saving them first... - */ - static char dbuffer[16]; /* Yes, 16: 4*3 digits + 3 '.' + 1 '\0' */ - char* s = inet_ntoa(*((struct in_addr*)&in)); if( s ) { - strcpy(dbuffer, s); - return dbuffer; + struct per_thread_data *data = get_per_thread_data(); + strcpy(data->ntoa_buffer, s); + return data->ntoa_buffer; } SetLastError(wsaErrno()); return NULL; diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 40e12a0..341b7e7 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -7073,7 +7073,6 @@ static void test_inet_ntoa(void) thread = CreateThread(NULL, 0, inet_ntoa_thread_proc, event, 0, &tid); WaitForSingleObject(event[0], 3000);
-todo_wine ok(!strcmp(str, "1.2.3.4"), "expected 1.2.3.4, got %s\n", str);
SetEvent(event[1]);