From: Fred Morcos Date: Fri, 10 Feb 2023 14:29:23 +0000 (+0100) Subject: Fix the confusing argument ordering of makeFromPEMFile X-Git-Tag: dnsdist-1.8.0-rc1~18^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e959b65ffb6ae8ec767798a554a290e0664999cf;p=thirdparty%2Fpdns.git Fix the confusing argument ordering of makeFromPEMFile --- diff --git a/pdns/dnssecinfra.cc b/pdns/dnssecinfra.cc index af32304e7d..10ba1442a7 100644 --- a/pdns/dnssecinfra.cc +++ b/pdns/dnssecinfra.cc @@ -170,7 +170,7 @@ std::unique_ptr DNSCryptoKeyEngine::makeFromISCString(DNSKEY return dpk; } -std::unique_ptr DNSCryptoKeyEngine::makeFromPEMFile(DNSKEYRecordContent& drc, const std::string& filename, std::FILE& inputFile, const uint8_t algorithm) +std::unique_ptr DNSCryptoKeyEngine::makeFromPEMFile(DNSKEYRecordContent& drc, const uint8_t algorithm, std::FILE& inputFile, const std::string& filename) { auto maker = DNSCryptoKeyEngine::make(algorithm); maker->createFromPEMFile(drc, filename, inputFile); diff --git a/pdns/dnssecinfra.hh b/pdns/dnssecinfra.hh index 6ef5dac6e2..d3a437d5bb 100644 --- a/pdns/dnssecinfra.hh +++ b/pdns/dnssecinfra.hh @@ -86,24 +86,22 @@ class DNSCryptoKeyEngine /** * \brief Creates a key engine from a PEM file. * - * Receives an open file handle with PEM contents and creates a key - * engine corresponding to the algorithm requested. + * Receives an open file handle with PEM contents and creates a key engine + * corresponding to the algorithm requested. * * \param[in] drc Key record contents to be populated. * - * \param[in] filename Only used for providing filename information - * in error messages. - * - * \param[in] fp An open file handle to a file containing PEM - * contents. - * * \param[in] algorithm Which algorithm to use. See * https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml * - * \return A key engine corresponding to the requested algorithm and - * populated with the contents of the PEM file. + * \param[in] fp An open file handle to a file containing PEM contents. + * + * \param[in] filename Only used for providing filename information in error messages. + * + * \return A key engine corresponding to the requested algorithm and populated with + * the contents of the PEM file. */ - static std::unique_ptr makeFromPEMFile(DNSKEYRecordContent& drc, const std::string& filename, std::FILE& inputFile, uint8_t algorithm); + static std::unique_ptr makeFromPEMFile(DNSKEYRecordContent& drc, uint8_t algorithm, std::FILE& inputFile, const std::string& filename); static std::unique_ptr makeFromISCString(DNSKEYRecordContent& drc, const std::string& content); static std::unique_ptr makeFromPublicKeyString(unsigned int algorithm, const std::string& raw); diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 4a95748d53..00cee06576 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -3481,7 +3481,7 @@ try } DNSKEYRecordContent drc; - shared_ptr key{DNSCryptoKeyEngine::makeFromPEMFile(drc, filename, *fp, algorithm)}; + shared_ptr key{DNSCryptoKeyEngine::makeFromPEMFile(drc, algorithm, *fp, filename)}; if (!key) { cerr << "Could not convert key from PEM to internal format" << endl; return 1; diff --git a/pdns/test-signers.cc b/pdns/test-signers.cc index fa974679a8..1c9b461424 100644 --- a/pdns/test-signers.cc +++ b/pdns/test-signers.cc @@ -463,7 +463,7 @@ BOOST_FIXTURE_TEST_CASE(test_generic_signers, Fixture) BOOST_REQUIRE(inputFile.get() != nullptr); DNSKEYRecordContent pemDRC; - shared_ptr pemKey{DNSCryptoKeyEngine::makeFromPEMFile(pemDRC, "", *inputFile, signer.algorithm)}; + shared_ptr pemKey{DNSCryptoKeyEngine::makeFromPEMFile(pemDRC, signer.algorithm, *inputFile, "")}; BOOST_CHECK_EQUAL(pemKey->convertToISC(), dcke->convertToISC());