From cba882b46d6d6df2af46dd62667c2a8e0b9f50d6 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 21 May 2015 14:34:54 +1000 Subject: [PATCH] http_get example: Fix printing of DNS resolved IP --- examples/http_get/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/http_get/main.c b/examples/http_get/main.c index 199f1a7..fc12910 100644 --- a/examples/http_get/main.c +++ b/examples/http_get/main.c @@ -42,7 +42,9 @@ void http_get_task(void *pvParameters) failures++; continue; } - printf("DNS lookup succeeded. IP=%s\r\n", inet_ntoa(res->ai_addr)); + /* Note: inet_ntoa is non-reentrant, look at ipaddr_ntoa_r for "real" code */ + struct in_addr *addr = &((struct sockaddr_in *)res->ai_addr)->sin_addr; + printf("DNS lookup succeeded. IP=%s\r\n", inet_ntoa(*addr)); int s = socket(res->ai_family, res->ai_socktype, 0); if(s < 0) {