浏览代码

make getaddrinfo return error if both host and service name are null

this case is specified as a mandatory ("shall fail") error.

based on patch by Julien Ramseier.
Rich Felker 9 年之前
父节点
当前提交
06bcf9bc94
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      src/network/getaddrinfo.c

+ 2 - 0
src/network/getaddrinfo.c

@@ -20,6 +20,8 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru
 		} sa;
 	} *out;
 
+	if (!host && !serv) return EAI_NONAME;
+
 	if (hint) {
 		family = hint->ai_family;
 		flags = hint->ai_flags;