From 001c1afb0a08912a6fdc7c462c53e221de4bc9f1 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Mon, 19 Sep 2022 15:38:00 -0400 Subject: res_mkquery: error out on consecutive final dots in name the main loop already errors out on zero-length labels within the name, but terminates before having a chance to check for an erroneous final zero-length label, instead producing a malformed query packet with a '.' byte instead of the terminating zero. rather than poke at the look logic, simply detect this condition early and error out without doing anything. this also fixes behavior of getaddrinfo when "." appears in the search domain list, which produces a name ending in ".." after concatenation, at least in the sense of no longer emitting malformed packets on the network. however, due to other issues, the lookup will still fail. --- src/network/res_mkquery.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/network') diff --git a/src/network/res_mkquery.c b/src/network/res_mkquery.c index 33f50cb9..614bf786 100644 --- a/src/network/res_mkquery.c +++ b/src/network/res_mkquery.c @@ -13,6 +13,7 @@ int __res_mkquery(int op, const char *dname, int class, int type, int n; if (l && dname[l-1]=='.') l--; + if (l && dname[l-1]=='.') return -1; n = 17+l+!!l; if (l>253 || buflen15u || class>255u || type>255u) return -1; -- cgit v1.2.3-70-g09d2