Re: unescaped double quotes in TXT record

Daryl Tester <[email protected]> Tue, 25 May 2010 15:39:47 +0930
Newsgroups gmane.network.djbdns
Message-ID <[email protected]>
(* Reply to dev null'd *)

Hugo Monteiro wrote:

> It's not a dig-ism. If it was, it would also show up in the dig 
> performed on the named server, right?

Mea culpa - I missed your named setup/response in your initial message.

However, I'm still not sure it's a not a dig-ism (potentially).  I
build a generic record thusly -

# :fqdn:n:rdata:ttl:timestamp:lo
:hp_4050._ipp._tcp.testernet:16:\160"qtotl=1" "rp=printers/xerox6130n" "ty=Xerox Phaser 6130N" "product=(Phaser 6130N)" "pdl=application/postscript":86400

I fire off a dig query (response trimmed):

# dig txt hp_4050._ipp._tcp.testernet @127.0.0.1
...
;; ANSWER SECTION:
hp_4050._ipp._tcp.testernet. 86400 IN   TXT     "\"qtotl=1\" \"rp=printers/xerox6130n\" \"ty=Xerox Phaser 6130N\" \"product=(Phaser 6130N)\" \"pdl=application/postscript\""

I tcpdump the same query:

15:18:32.775440 IP 127.0.0.1.53 > 127.0.0.1.46418: 2993*- 1/1/1 TXT ""qtotl=1" "rp=printers/xerox6130n" "ty=Xerox Phaser 6130N" "product=(Phaser 6130N)" "pdl=application/postscript"" (203)
        0x0000:  4500 00e7 0000 4000 4011 3c04 7f00 0001  E.....@.@.<.....
        0x0010:  7f00 0001 0035 b552 00d3 fee6 0bb1 8500  .....5.R........
        0x0020:  0001 0001 0001 0001 0768 705f 3430 3530  .........hp_4050
        0x0030:  045f 6970 7004 5f74 6370 0974 6573 7465  ._ipp._tcp.teste
        0x0040:  726e 6574 0000 1000 01c0 0c00 1000 0100  rnet............
        0x0050:  0151 8000 7170 2271 746f 746c 3d31 2220  .Q..qp"qtotl=1".
        0x0060:  2272 703d 7072 696e 7465 7273 2f78 6572  "rp=printers/xer
        0x0070:  6f78 3631 3330 6e22 2022 7479 3d58 6572  ox6130n"."ty=Xer
        0x0080:  6f78 2050 6861 7365 7220 3631 3330 4e22  ox.Phaser.6130N"
        0x0090:  2022 7072 6f64 7563 743d 2850 6861 7365  ."product=(Phase
        0x00a0:  7220 3631 3330 4e29 2220 2270 646c 3d61  r.6130N)"."pdl=a
        0x00b0:  7070 6c69 6361 7469 6f6e 2f70 6f73 7473  pplication/posts
        0x00c0:  6372 6970 7422 c01e 0002 0001 0003 f480  cript"..........
        0x00d0:  0005 026e 73c0 1ec0 b600 0100 0100 03f4  ...ns...........
        0x00e0:  8000 047f 0000 01                        .......

No leading/trailing or backquoted quotes in the hexdumped query (you'll note that
tcpdump also surrounds the text response with quotes).  dnsq produces the following:

# dnsq txt hp_4050._ipp._tcp.testernet 127.0.0.1
16 hp_4050._ipp._tcp.testernet:
203 bytes, 1+1+1+1 records, response, authoritative, noerror
query: 16 hp_4050._ipp._tcp.testernet
answer: hp_4050._ipp._tcp.testernet 86400 16 p"qtotl=1"\040"rp=printers/xerox6130n"\040"ty=Xerox\040Phaser\0406130N"\040"product=(Phaser\0406130N)"\040"pdl=application/postscript"

Are you using generic records or something else (potentially txt?).

> also, dnsq response, for the tinydns server is
> 
> $ dnsq txt hp_4050._ipp._tcp.dev.hmonteiro.net 192.168.56.102
> 16 hp_4050._ipp._tcp.dev.hmonteiro.net:
> 252 bytes, 1+1+2+2 records, response, authoritative, noerror
> query: 16 hp_4050._ipp._tcp.dev.hmonteiro.net
> answer: hp_4050._ipp._tcp.dev.hmonteiro.net 60 16 
> {"qtotl=1"\040"rp=printers/HP"\040"ty=HP\040LaserJet\0404050\040Series\040PS"\040"product=(HP\040LaserJet\0404050\040Series)"\040"pdl=application/postscript"
> authority: dev.hmonteiro.net 604800 NS ns1.dev.hmonteiro.net
> additional: ns1.dev.hmonteiro.net 604800 A 192.168.56.102

Isn't this the correct response you're seeking?

> $ dnsq txt xerox_phaser_6130n._ipp._tcp.dev.hmonteiro.net 192.168.56.103
> 16 xerox_phaser_6130n._ipp._tcp.dev.hmonteiro.net:
> 212 bytes, 1+1+1+1 records, response, authoritative, weird ra, noerror
> query: 16 xerox_phaser_6130n._ipp._tcp.dev.hmonteiro.net
> answer: xerox_phaser_6130n._ipp._tcp.dev.hmonteiro.net 604800 16 
> \007qtotl=1\026rp=printers/xerox6130n\025ty=Xerox\040Phaser\0406130N\026product=(Phaser\0406130N)\032pdl=application/postscript
> authority: dev.hmonteiro.net 604800 NS ns2.dev.hmonteiro.net
> additional: ns2.dev.hmonteiro.net 604800 A 192.168.56.103
> 
> i'm also finding the bind response weird .. \007 ?  \026 ?  \025 ?

They look like lengths of the individual text portions - i.e.

7: qtotl=1
22: rp=printers/xerox6130n
21: ty=Xerox Phaser 6130N
etc.

(note octal to decimal conversion).

> (but IT WORKS)

Hmmm, OK, looking at Section 6 of <http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt>
shows that it's supposed to be in the format that the bind server is returning (that is,
each key/value pair needs to have a length byte preceeding it).  I suspect the format you're
feeding into djbdns doesn't have that.


(And yippee, another protocol overloading the TXT record).

-- 
Regards,
  Daryl Tester

Member of the Amalgamated Australian Association Against Apostrophe Abuse.
(formerly the 6A's - no, wait ...).