소스 검색

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;