瀏覽代碼

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 年之前
父節點
當前提交
c674b981d1
共有 1 個文件被更改,包括 9 次插入1 次删除
  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) {