The calls to RES_SET_H_ERRNO() macro on error paths wind up

dereferencing an uninitialized res.

PR:		202142
Submitted by:	Sean Boudreau
MFC after:	1 week
This commit is contained in:
Hajimu UMEMOTO 2015-12-10 11:11:44 +00:00
parent ad32bf978a
commit 4eb17fd786
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=292059

View File

@ -2208,6 +2208,8 @@ _dns_getaddrinfo(void *rv, void *cb_data, va_list ap)
memset(&sentinel, 0, sizeof(sentinel));
cur = &sentinel;
res = __res_state();
buf = malloc(sizeof(*buf));
if (!buf) {
RES_SET_H_ERRNO(res, NETDB_INTERNAL);
@ -2254,7 +2256,6 @@ _dns_getaddrinfo(void *rv, void *cb_data, va_list ap)
return NS_UNAVAIL;
}
res = __res_state();
if ((res->options & RES_INIT) == 0 && res_ninit(res) == -1) {
RES_SET_H_ERRNO(res, NETDB_INTERNAL);
free(buf);