浏览代码

Cast len to unsigned

On Windows the length to getnameinfo is a DWORD and socklen_t is an
integer. This results in sign conversion. On POSIX socklen_t is an
unsigned integer. Let's cast to unsigned to make both sides happy.
Matt Clarkson 10 年之前
父节点
当前提交
4ce8508133
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/civetweb.c

+ 2 - 2
src/civetweb.c

@@ -1454,12 +1454,12 @@ static void sockaddr_to_string(char *buf, size_t len, const union usa *usa)
 
 	if (usa->sa.sa_family == AF_INET) {
 		getnameinfo(
-		    &usa->sa, sizeof(usa->sin), buf, (socklen_t)len, NULL, 0, NI_NUMERICHOST);
+		    &usa->sa, sizeof(usa->sin), buf, (unsigned)len, NULL, 0, NI_NUMERICHOST);
 	}
 #if defined(USE_IPV6)
 	else if (usa->sa.sa_family == AF_INET6) {
 		getnameinfo(
-		    &usa->sa, sizeof(usa->sin6), buf, (socklen_t)len, NULL, 0, NI_NUMERICHOST);
+		    &usa->sa, sizeof(usa->sin6), buf, (unsigned)len, NULL, 0, NI_NUMERICHOST);
 	}
 #endif