Source: djbdns
Version: 1:1.05-22
Severity: important
Tags: patch
X-Debbugs-Cc: [email protected]
Dear Maintainer,
your djbdns:src package contains a patch
(0004-tinydns-data-SRV-axfr-get-SRV-PTR-patches.patch) that adds SRV support
(and some extra PTR bits, which this ticket is not about).
While using axfr-get and tinydns-data today, I discovered that the SRV parts
are broken. Specifically, after passing an SRV record from a working DNS
server, via axfr-get, to tinydns-data, the resulting data.cdb file contains the
wrong data:
original, good:_imap._tcp.example.com. 120 IN SRV 0 1 143 blah.test.com.
new, bad: _imap._tcp.example.com. 120 IN SRV 1 143 0 blah.test.com.
While investigating this, I realised that the documentation
(Sfqdn:ip:x:port:weight:priority:ttl:timestamp
), the axfr-get patch, and the tinydns-data patch, all disagree with eachother.
I have tried to find the original source of the patch, but that appears to be
long gone. However, identically broken copies of it exist in many places.
Here's one place where a user also spotted part of the problem:
https://github.com/balena/djbdns-srv-naptr/pull/2
Below you will find a patch I wrote that happens to contain that patch too
(fixing axfr-get), plus a fix for tinydns-data. It makes axfr-get and
tinydns-data conform to the documentation at the top of 0004-.
It should be possible to merge my patch into the 0004 patch, but given how many
identical copies of 0004 exist on the Internet, it might make more sense to
keep my patch in a separate file in debian/patches/.
It would make me quite happy if this patch could make it into Trixie.
--- djbdns-1.05.orig/axfr-get.c
+++ djbdns-1.05/axfr-get.c
@@ -215,11 +215,11 @@ unsigned int doit(char *buf,unsigned int
if (!dns_domain_todot_cat(&line,d1)) return 0;
if (!stralloc_cats(&line,"::")) return 0;
pos = x_copy(buf,len,pos,data,2);
- uint16_unpack_big(data,&dist);
+ uint16_unpack_big(data,&port);
pos = x_copy(buf,len,pos,data,2);
uint16_unpack_big(data,&weight);
pos = x_copy(buf,len,pos,data,2);
- uint16_unpack_big(data,&port);
+ uint16_unpack_big(data,&dist);
x_getname(buf,len,pos,&d1);
if (!dns_domain_todot_cat(&line,d1)) return 0;
if (!stralloc_cats(&line,".:")) return 0;
--- djbdns-1.05.orig/tinydns-data.c
+++ djbdns-1.05/tinydns-data.c
@@ -393,11 +393,11 @@ int main()
}
if (!dns_domain_fromdot(&d2,f[2].s,f[2].len)) nomem();
- if (!stralloc_0(&f[4])) nomem();
- if (!scan_ulong(f[4].s,&u)) u = 0;
- uint16_pack_big(srv,u);
if (!stralloc_0(&f[5])) nomem();
if (!scan_ulong(f[5].s,&u)) u = 0;
+ uint16_pack_big(srv,u);
+ if (!stralloc_0(&f[4])) nomem();
+ if (!scan_ulong(f[4].s,&u)) u = 0;
uint16_pack_big(srv + 2,u);
if (!stralloc_0(&f[3])) nomem();
if (!scan_ulong(f[3].s,&u)) nomem();
-- System Information:
Debian Release: 13.0
APT prefers testing-security
APT policy: (500, 'testing-security'), (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 6.12.27-amd64 (SMP w/22 CPU threads; PREEMPT)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8),
LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
--- djbdns-1.05.orig/axfr-get.c
+++ djbdns-1.05/axfr-get.c
@@ -215,11 +215,11 @@ unsigned int doit(char *buf,unsigned int
if (!dns_domain_todot_cat(&line,d1)) return 0;
if (!stralloc_cats(&line,"::")) return 0;
pos = x_copy(buf,len,pos,data,2);
- uint16_unpack_big(data,&dist);
+ uint16_unpack_big(data,&port);
pos = x_copy(buf,len,pos,data,2);
uint16_unpack_big(data,&weight);
pos = x_copy(buf,len,pos,data,2);
- uint16_unpack_big(data,&port);
+ uint16_unpack_big(data,&dist);
x_getname(buf,len,pos,&d1);
if (!dns_domain_todot_cat(&line,d1)) return 0;
if (!stralloc_cats(&line,".:")) return 0;
--- djbdns-1.05.orig/tinydns-data.c
+++ djbdns-1.05/tinydns-data.c
@@ -393,11 +393,11 @@ int main()
}
if (!dns_domain_fromdot(&d2,f[2].s,f[2].len)) nomem();
- if (!stralloc_0(&f[4])) nomem();
- if (!scan_ulong(f[4].s,&u)) u = 0;
- uint16_pack_big(srv,u);
if (!stralloc_0(&f[5])) nomem();
if (!scan_ulong(f[5].s,&u)) u = 0;
+ uint16_pack_big(srv,u);
+ if (!stralloc_0(&f[4])) nomem();
+ if (!scan_ulong(f[4].s,&u)) u = 0;
uint16_pack_big(srv + 2,u);
if (!stralloc_0(&f[3])) nomem();
if (!scan_ulong(f[3].s,&u)) nomem();