ensure the head entry of addrinfo chain has non-NULL ai_canonname to be
compliant with RFC3493.

PR: standards/114910
Approved by:   ume (mentor)
lib/libc/net/getaddrinfo.c:	1.86
This commit is contained in:
jinmei 2007-09-28 06:23:03 +00:00
parent 1d2954da88
commit a5dfa0a1a7

View File

@ -570,8 +570,24 @@ good:
* in the most efficient order.
*/
if (hints == NULL || !(hints->ai_flags & AI_PASSIVE)) {
if (!numeric)
if (!numeric) {
char *canonname;
canonname =
sentinel.ai_next->ai_canonname;
if (canonname != NULL) {
sentinel.ai_next->ai_canonname
= NULL;
}
(void)reorder(&sentinel);
if (sentinel.ai_next->ai_canonname ==
NULL) {
sentinel.ai_next->ai_canonname
= canonname;
} else {
free(canonname);
}
}
}
*res = sentinel.ai_next;
return SUCCESS;