From: Niall O'Reilly Date: Thu, 19 Sep 2019 13:38:14 +0000 (+0100) Subject: doh: avoid truncating DNS QTYPE to lower octet X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d59addff6af9d32b7b92b61ebd74915c2ff13e8;p=curl doh: avoid truncating DNS QTYPE to lower octet Closes #4381 --- diff --git a/lib/doh.c b/lib/doh.c index e97e4fe7a..5a76d6d87 100644 --- a/lib/doh.c +++ b/lib/doh.c @@ -135,8 +135,10 @@ UNITTEST DOHcode doh_encode(const char *host, } } while(1); - *dnsp++ = '\0'; /* upper 8 bit TYPE */ - *dnsp++ = (unsigned char)dnstype; + /* There are assigned TYPE codes beyond 255: use range [1..65535] */ + *dnsp++ = (unsigned char)(255 & (dnstype>>8)); /* upper 8 bit TYPE */ + *dnsp++ = (unsigned char)(255 & dnstype); /* lower 8 bit TYPE */ + *dnsp++ = '\0'; /* upper 8 bit CLASS */ *dnsp++ = DNS_CLASS_IN; /* IN - "the Internet" */