Просмотр исходного кода

Fix recent changes in parse_port_string

bel 8 лет назад
Родитель
Сommit
bf2468a880
2 измененных файлов с 10 добавлено и 1 удалено
  1. 4 1
      src/civetweb.c
  2. 6 0
      test/private.c

+ 4 - 1
src/civetweb.c

@@ -10766,7 +10766,10 @@ parse_port_string(const struct vec *vec, struct socket *so, int *ip_version)
 
 	} else if ((vec->ptr[0] == '+')
 	           && (sscanf(vec->ptr + 1, "%u%n", &port, &len) == 1)) {
-/* Port is specified with a +, bind to IPv6 and IPv4, INADDR_ANY */
+
+		/* Port is specified with a +, bind to IPv6 and IPv4, INADDR_ANY */
+		/* Add 1 to len for the + character we skipped before */
+		len++;
 
 #if defined(USE_IPV6)
 		/* Set socket family to IPv6, do not use IPV6_V6ONLY */

+ 6 - 0
test/private.c

@@ -720,6 +720,12 @@ make_private_suite(void)
 void
 MAIN_PRIVATE(void)
 {
+#if defined(_WIN32)
+	/* test_parse_port_string requires WSAStartup for IPv6 */
+	WSADATA data;
+	WSAStartup(MAKEWORD(2, 2), &data);
+#endif
+
 	test_alloc_vprintf(0);
 	test_mg_vsnprintf(0);
 	test_remove_double_dots_and_double_slashes(0);