toybox icon indicating copy to clipboard operation
toybox copied to clipboard

fix-host_txt_rdata.patch

Open nomas2000 opened this issue 3 years ago • 2 comments

The TXT RR RDATA returned by DNS servers is rfc1035 <character-string>s
<character-string> is a single length octet followed by that number of characters. 
... notice how the first RDATA byte is usually 1-less than the RDLENGTH?

If max allowed TXT record length is 255 chars + we assume only one char string,
then we can just verify and discard the first byte of TXT RDATA. If first byte
doesn't match (1 shorter than RDLENGTH) then don't discard it.
... throw an error instead? ... ignore the response as invalid?


--- toybox-0.8.6/toys/pending/host.c_ORIG	2022-07-25 17:30:48.958174663 +0000
+++ toybox-0.8.6/toys/pending/host.c	2022-07-25 17:32:40.178209094 +0000
@@ -170,6 +170,10 @@
         dn_expand(abuf, abuf+alen, p, plname, sizeof(plname));
         break;
       case PL_TEXT:
+        if ((pllen > 1) && (pllen <= 256) && (pllen-1 == p[0])) {
+          pllen--;
+          p++;
+        }
         snprintf(plname, sizeof(plname), "\"%.*s\"", pllen, p);
         break;
       case PL_SOA:

nomas2000 avatar Nov 02 '22 17:11 nomas2000

If you do these as pull requests instead of issues I can easily apply them with your supplied metadata. (I.E. proper attribution.) FYI.

landley avatar Nov 02 '22 20:11 landley

almost two whole years ... probably time to just do it without attribution?

enh-google avatar Aug 02 '24 20:08 enh-google