Browse Source

Ignore warning around deprecated gethostbyname

gethostbyname has been dperecated on all platforms as it is not
re-entrant. it has been replaced with getaddrinfo. The signature
of getaddrinfo is different on Windows to POSIX. We will need to
address this shortcoming in the future.
Matt Clarkson 10 years ago
parent
commit
c674b981d1
1 changed files with 9 additions and 1 deletions
  1. 9 1
      src/civetweb.c

+ 9 - 1
src/civetweb.c

@@ -4584,8 +4584,16 @@ static SOCKET conn2(struct mg_context *ctx /* may be null */,
 		snprintf(ebuf, ebuf_len, "%s", "NULL host");
 	} else if (use_ssl && SSLv23_client_method == NULL) {
 		snprintf(ebuf, ebuf_len, "%s", "SSL is not initialized");
-		/* TODO(lsm): use something threadsafe instead of gethostbyname() */
+#ifdef _MSC_VER
+#pragma warning(push)
+/* TODO(lsm): use something threadsafe instead of gethostbyname() */
+/* getaddrinfo is the replacement here but isn't cross platform */
+#pragma warning(disable: 4996)
+#endif
 	} else if ((he = gethostbyname(host)) == NULL) {
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
 		snprintf(
 		    ebuf, ebuf_len, "gethostbyname(%s): %s", host, strerror(ERRNO));
 	} else if ((sock = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {