purplepixie/phpdns

Bug: InvalidQueryTypeId exception

Closed this issue · 7 comments

I was looking for TXT DNS records of this domain artepapel.cl it always throws the InvalidQueryTypeId exception.

Here is the debug info (After commented out the exception).

DNSQuery Class Initialised
Question: artepapel.cl (type=TXT/16)
Header Length: 30 Bytes
Read Buffer Size 30
ID=19883, Type=1, OPCODE=0, AA=0, TC=1, RD=1, RA=1, RCODE=0
Error: Response too big for UDP, retry with TCP
DNSQuery Class Initialised
Question: artepapel.cl (type=TXT/16)
Header Length: 30 Bytes
TCP Stream Length Limit 549
Read Buffer Size 549
ID=1597, Type=1, OPCODE=0, AA=0, TC=0, RD=1, RA=1, RCODE=0
Query Returned 11 Answers
Found 1 Questions
Label Offset: 12
Label artepapel.cl len 2
Record Type 16 Class 1 TTL 20527 Length 46
Label Offset: 12
Label artepapel.cl len 2
Record Type 16 Class 1 TTL 20527 Length 30
Label Offset: 12
Label artepapel.cl len 2
Record Type 16 Class 1 TTL 20527 Length 24
Label Offset: 12
Label artepapel.cl len 2
Record Type 16 Class 1 TTL 20527 Length 45
Label Offset: 12
Label artepapel.cl len 2
Record Type 16 Class 1 TTL 20527 Length 1
Label  len 1
Record Type 49164 Class 16 TTL 65536 Length 20527
Label  len 1
Record Type 12335 Class 15393 TTL 757932103 Length 27759
Label Offset: 8801
Label  len 2
Record Type 27680 Class 29545 TTL 1952784500 Length 24935
Label (gtag.js) - Google Ads -->�

The exception throws near this 49164 type ID. Using this 8.8.8.8 DNS server.

This appears to be a result of a blank TXT record for the domain not being picked up correctly. DIG output:

; <<>> DiG 9.10.6 <<>> -t TXT artepapel.cl
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21086
;; flags: qr rd ra; QUERY: 1, ANSWER: 11, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;artepapel.cl.                  IN      TXT

;; ANSWER SECTION:
artepapel.cl.           85668   IN      TXT     "facebook-domain-verification=zzaijoov0g29pnsk0lonvq22vwx0vh"
artepapel.cl.           85668   IN      TXT     "<!-- Global site tag (gtag.js) - Google Ads -->"
artepapel.cl.           85668   IN      TXT     "  window.dataLayer = window.dataLayer || [];"
artepapel.cl.           85668   IN      TXT     "<script>"
artepapel.cl.           85668   IN      TXT     "  gtag(config, AW-746465677);"
artepapel.cl.           85668   IN      TXT     "</script>"
artepapel.cl.           85668   IN      TXT     "  gtag(js, new Date());"
artepapel.cl.           85668   IN      TXT     "v=spf1 include:zoho.com -all"
artepapel.cl.           85668   IN      TXT     ""
artepapel.cl.           85668   IN      TXT     "<script async src=https://www.googletagmanager.com/gtag/js?id=AW-746465677></script>"
artepapel.cl.           85668   IN      TXT     "  function gtag(){dataLayer.push(arguments);}"

;; Query time: 0 msec
;; SERVER: 192.168.0.4#53(192.168.0.4)
;; WHEN: Mon May 27 13:04:39 BST 2024
;; MSG SIZE  rcvd: 560

Although the order of TXT isn't consistent and therefore breaks at different places, but does appear to be the blank.

Under investigation.

Also sometimes shows 49172 record type - confirmed this seems an error with TXT "" records which should be handled (but aren't!)

Branch emptytxt has a trial fix for this, skips a character ahead when TXT records have a length of 1 (empty string), skipping over char which is causing issue. Testing seems to show no impact on other valid TXT.

Merged to master and passing CI

Release 2.1.1 includes this fix https://packagist.org/packages/purplepixie/phpdns - will keep this open pending testing. @uksarkar thank you very much for finding this and please do try the latest release and let me know how you get on.

@purplepixie thank you for the quick response, it looks ok for now. Maybe you can close the issue now.

Many thanks @uksarkar. Issue resolved with 2.1.1