in performing dns lookups, check result from res_mkquery
authorNatanael Copa <ncopa@alpinelinux.org>
Wed, 25 May 2016 09:22:13 +0000 (11:22 +0200)
committerRich Felker <dalias@aerifal.cx>
Wed, 29 Jun 2016 15:57:53 +0000 (11:57 -0400)
don't send a query that may be malformed.

src/network/lookup_name.c

index 86f90ac1b74b9b11183d8a495667da2d9989b7f4..d3d97b48d1aebf889bb33eeb2a8dc92ed003b82b 100644 (file)
@@ -145,11 +145,15 @@ static int name_from_dns(struct address buf[static MAXADDRS], char canon[static
        if (family != AF_INET6) {
                qlens[nq] = __res_mkquery(0, name, 1, RR_A, 0, 0, 0,
                        qbuf[nq], sizeof *qbuf);
+               if (qlens[nq] == -1)
+                       return EAI_NONAME;
                nq++;
        }
        if (family != AF_INET) {
                qlens[nq] = __res_mkquery(0, name, 1, RR_AAAA, 0, 0, 0,
                        qbuf[nq], sizeof *qbuf);
+               if (qlens[nq] == -1)
+                       return EAI_NONAME;
                nq++;
        }