• Bug#1108915: unblock: pdns/4.9.7-1 [pre-approval] (5/5)

    From Chris =?utf-8?Q?Hofst=C3=A4dtler?=@1:229/2 to All on Mon Jul 7 18:10:01 2025
    [continued from previous message]

    if (parts[0].size() >= 32) {
    auto ippart = parts[0].substr(parts[0].size()-32);
    auto fulladdress =
    @@ -1002,57 +1008,63 @@
    ippart.substr(24, 4) + ":" +
    ippart.substr(28, 4);

    - ComboAddress ca(fulladdress);
    - return ca.toString();
    + ComboAddress address(fulladdress);
    + return address.toString();
    }
    }
    + return allZerosIP;
    + } catch (const PDNSException &e) {
    + return allZerosIP;
    }
    -
    - return std::string("::");
    });
    - lua.writeFunction("createReverse6", [](string format, boost::optional<std::unordered_map<string,string>> e){
    + lua.writeFunction("createReverse6", [](const string &format, boost::optional<std::unordered_map<string,string>> excp){
    vector<ComboAddress> candidates;

    try {
    auto labels= s_lua_record_ctx->qname.getRawLabels();
    - if(labels.size()<32)
    + if (labels.size()<32) {
    return std::string("unknown");
    + }
    boost::format fmt(format);
    fmt.exceptions( boost::io::all_error_bits ^ ( boost::io::too_many_args_bit | boost::io::too_few_args_bit ) );


    string together;
    vector<string> quads;
    - for(int i=0; i<8; ++i) {
    - if(i)
    - together+=":";
    + for (int chunk = 0; chunk < 8; ++chunk) {
    + if (chunk != 0) {
    + together += ":";
    + }
    string lquad;
    - for(int j=0; j <4; ++j) {
    - lquad.append(1, labels[31-i*4-j][0]);
    - together += labels[31-i*4-j][0];
    + for (int quartet = 0; quartet < 4; ++quartet) {
    + lquad.append(1, labels[31 - chunk * 4 - quartet][0]);
    + together += labels[31 - chunk * 4 - quartet][0];
    }
    quads.push_back(lquad);
    }
    - ComboAddress ip6(together,0);
    + ComboAddress ip6(together,0);

    - if(e) {
    - auto& addrs=*e;
    + if (excp) {
    + auto& addrs=*excp;
    for(const auto& addr: addrs) {
    // this makes sure we catch all forms of the address
    - if(ComboAddress(addr.first,0)==ip6)
    + if (ComboAddress(addr.first, 0) == ip6) {
    return addr.second;
    + }
    }
    }

    string dashed=ip6.toString();
    boost::replace_all(dashed, ":", "-");

    - for(int i=31; i>=0; --i)
    - fmt % labels[i];
    + for (int byte = 31; byte >= 0; --byte) {
    + fmt % labels[byte];
    + }
    fmt % dashed;

    - for(const auto& lquad : quads)
    + for(const auto& lquad : quads) {
    fmt % lquad;
    + }

    return fmt.str();
    }
    diff -Nru pdns-4.9.4/pdns/test-tsig.cc pdns-4.9.7/pdns/test-tsig.cc
    --- pdns-4.9.4/pdns/test-tsig.cc 2025-02-06 16:17:38.000000000 +0100
    +++ pdns-4.9.7/pdns/test-tsig.cc 2025-07-07 09:42:15.000000000 +0200
    @@ -141,6 +141,17 @@
    checkTSIG(tsigName, tsigAlgo.makeLowerCase(), tsigSecret, packet);
    }

    +BOOST_AUTO_TEST_CASE(test_TSIG_different_case_name) {
    + DNSName tsigName("tsig.Name");
    + DNSName tsigAlgo("HMAC-MD5.SIG-ALG.REG.INT");
    + DNSName qname("test.valid.tsig");
    + string tsigSecret("verysecret");
    +
    + vector<uint8_t> packet = generateTSIGQuery(qname, tsigName, tsigAlgo, tsigSecret);
    +
    + checkTSIG(tsigName.makeLowerCase(), tsigAlgo.makeLowerCase(), tsigSecret, packet);
    +}
    +
    BOOST_AUTO_TEST_CASE(test_TSIG_different_name_same_algo) {
    DNSName tsigName("tsig.name");
    DNSName tsigAlgo("HMAC-MD5.SIG-ALG.REG.INT");

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)
  • From Sebastian Ramacher@1:229/2 to All on Tue Jul 8 08:10:01 2025
    [continued from previous message]

    lua.writeFunction("createForward6", []() {
    - DNSName rel=s_lua_record_ctx->qname.makeRelative(s_lua_record_ctx->zone);
    - auto parts = rel.getRawLabels();
    - if(parts.size()==8) {
    - string tot;
    - for(int i=0; i<8; ++i) {
    - if(i)
    - tot.append(1,':');
    - tot+=parts[i];
    + static string allZerosIP{"::"};
    + try {
    + DNSName rel{s_lua_record_ctx->qname.makeRelative(s_lua_record_ctx->zone)};
    +
    + auto parts = rel.getRawLabels();
    + if (parts.size() == 8) {
    + string tot;
    + for (int chunk = 0; chunk < 8; ++chunk) {
    + if (chunk != 0) {
    + tot.append(1, ':');
    + }
    + tot += parts.at(chunk);
    + }
    + ComboAddress address(tot);
    + return address.toString();
    }
    - ComboAddress ca(tot);
    - return ca.toString();
    - }
    - else if(parts.size()==1) {
    - if (parts[0].find('-') != std::string::npos) {
    - boost::replace_all(parts[0],"-",":");
    - ComboAddress ca(parts[0]);
    - return ca.toString();
    - } else {
    + if (parts.size() == 1) {
    + if (parts[0].find('-') != std::string::npos) {
    + std::replace(parts[0].begin(), parts[0].end(), '-', ':');
    + ComboAddress address(parts[0]);
    + return address.toString();
    + }
    if (parts[0].size() >= 32) {
    auto ippart = parts[0].substr(parts[0].size()-32);
    auto fulladdress =
    @@ -1002,57 +1008,63 @@
    ippart.substr(24, 4) + ":" +
    ippart.substr(28, 4);

    - ComboAddress ca(fulladdress);
    - return ca.toString();
    + ComboAddress address(fulladdress);
    + return address.toString();
    }
    }
    + return allZerosIP;
    + } catch (const PDNSException &e) {
    + return allZerosIP;
    }
    -
    - return std::string("::");
    });
    - lua.writeFunction("createReverse6", [](string format, boost::optional<std::unordered_map<string,string>> e){
    + lua.writeFunction("createReverse6", [](const string &format, boost::optional<std::unordered_map<string,string>> excp){
    vector<ComboAddress> candidates;

    try {
    auto labels= s_lua_record_ctx->qname.getRawLabels();
    - if(labels.size()<32)
    + if (labels.size()<32) {
    return std::string("unknown");
    + }
    boost::format fmt(format);
    fmt.exceptions( boost::io::all_error_bits ^ ( boost::io::too_many_args_bit | boost::io::too_few_args_bit ) );


    string together;
    vector<string> quads;
    - for(int i=0; i<8; ++i) {
    - if(i)
    - together+=":";
    + for (int chunk = 0; chunk < 8; ++chunk) {
    + if (chunk != 0) {
    + together += ":";
    + }
    string lquad;
    - for(int j=0; j <4; ++j) {
    - lquad.append(1, labels[31-i*4-j][0]);
    - together += labels[31-i*4-j][0];
    + for (int quartet = 0; quartet < 4; ++quartet) {
    + lquad.append(1, labels[31 - chunk * 4 - quartet][0]);
    + together += labels[31 - chunk * 4 - quartet][0];
    }
    quads.push_back(lquad);
    }
    - ComboAddress ip6(together,0);
    + ComboAddress ip6(together,0);

    - if(e) {
    - auto& addrs=*e;
    + if (excp) {
    + auto& addrs=*excp;
    for(const auto& addr: addrs) {
    // this makes sure we catch all forms of the address
    - if(ComboAddress(addr.first,0)==ip6)
    + if (ComboAddress(addr.first, 0) == ip6) {
    return addr.second;
    + }
    }
    }

    string dashed=ip6.toString();
    boost::replace_all(dashed, ":", "-");

    - for(int i=31; i>=0; --i)
    - fmt % labels[i];
    + for (int byte = 31; byte >= 0; --byte) {
    + fmt % labels[byte];
    + }
    fmt % dashed;

    - for(const auto& lquad : quads)
    + for(const auto& lquad : quads) {
    fmt % lquad;
    + }

    return fmt.str();
    }
    diff -Nru pdns-4.9.4/pdns/test-tsig.cc pdns-4.9.7/pdns/test-tsig.cc
    --- pdns-4.9.4/pdns/test-tsig.cc 2025-02-06 16:17:38.000000000 +0100
    +++ pdns-4.9.7/pdns/test-tsig.cc 2025-07-07 09:42:15.000000000 +0200
    @@ -141,6 +141,17 @@
    checkTSIG(tsigName, tsigAlgo.makeLowerCase(), tsigSecret, packet);
    }

    +BOOST_AUTO_TEST_CASE(test_TSIG_different_case_name) {
    + DNSName tsigName("tsig.Name");
    + DNSName tsigAlgo("HMAC-MD5.SIG-ALG.REG.INT");
    + DNSName qname("test.valid.tsig");
    + string tsigSecret("verysecret");
    +
    + vector<uint8_t> packet = generateTSIGQuery(qname, tsigName, tsigAlgo, tsigSecret);
    +
    + checkTSIG(tsigName.makeLowerCase(), tsigAlgo.makeLowerCase(), tsigSecret, packet);
    +}
    +
    BOOST_AUTO_TEST_CASE(test_TSIG_different_name_same_algo) {
    DNSName tsigName("tsig.name");
    DNSName tsigAlgo("HMAC-MD5.SIG-ALG.REG.INT");


    --
    Sebastian Ramacher

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)