Author: ume
Date: Thu Dec 17 16:09:15 2015
New Revision: 292404
URL: https://svnweb.freebsd.org/changeset/base/292404

Log:
  MFC r292059:
    The calls to RES_SET_H_ERRNO() macro on error paths wind up
    dereferencing an uninitialized res.
  
  PR:           202142
  Submitted by: Sean Boudreau

Modified:
  stable/9/lib/libc/net/getaddrinfo.c
Directory Properties:
  stable/9/lib/libc/   (props changed)

Modified: stable/9/lib/libc/net/getaddrinfo.c
==============================================================================
--- stable/9/lib/libc/net/getaddrinfo.c Thu Dec 17 16:08:28 2015        
(r292403)
+++ stable/9/lib/libc/net/getaddrinfo.c Thu Dec 17 16:09:15 2015        
(r292404)
@@ -2202,6 +2202,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);
@@ -2248,7 +2250,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);
_______________________________________________
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"

Reply via email to