svn commit: r292059 - head/lib/libc/net

Hajimu UMEMOTO ume at FreeBSD.org
Thu Dec 10 11:11:45 UTC 2015


Author: ume
Date: Thu Dec 10 11:11:44 2015
New Revision: 292059
URL: https://svnweb.freebsd.org/changeset/base/292059

Log:
  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

Modified:
  head/lib/libc/net/getaddrinfo.c

Modified: head/lib/libc/net/getaddrinfo.c
==============================================================================
--- head/lib/libc/net/getaddrinfo.c	Thu Dec 10 10:37:12 2015	(r292058)
+++ head/lib/libc/net/getaddrinfo.c	Thu Dec 10 11:11:44 2015	(r292059)
@@ -2208,6 +2208,8 @@ _dns_getaddrinfo(void *rv, void *cb_data
 	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
 		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);


More information about the svn-src-head mailing list