Skip to content

Commit

Permalink
doh: avoid truncating DNS QTYPE to lower octet
Browse files Browse the repository at this point in the history
Closes #4381
  • Loading branch information
Niall O'Reilly authored and bagder committed Sep 19, 2019
1 parent 0a4ecbd commit 0d59add
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/doh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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" */

Expand Down

0 comments on commit 0d59add

Please sign in to comment.