• Bug#1109285: djbdns: SRV patch is broken

    From Peter van Dijk@21:1/5 to All on Mon Jul 14 20:00:01 2025
    This is a multi-part MIME message sent by reportbug.


    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
  • From Peter van Dijk@21:1/5 to All on Mon Jul 14 20:20:02 2025
    On re-reading my patch, I see that while the behaviour is now correct, some variables are now mis-named (but consistently!). I'll send a new one soon.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)