From: Otto Moerbeek Date: Wed, 4 Feb 2026 12:21:23 +0000 (+0100) Subject: Depending on openssl version, base 64 decode is more or less strict X-Git-Tag: rec-5.5.0-alpha0~30^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df0141a386b25ee55700516a02cd6a293f566ccd;p=thirdparty%2Fpdns.git Depending on openssl version, base 64 decode is more or less strict Signed-off-by: Otto Moerbeek --- diff --git a/pdns/base64.cc b/pdns/base64.cc index 5d3081b23f..def6293a5a 100644 --- a/pdns/base64.cc +++ b/pdns/base64.cc @@ -23,6 +23,7 @@ #include "config.h" #include "base64.hh" +#include #include #include #include @@ -86,7 +87,7 @@ std::string Base64Encode(const std::string& src) bio = BIO_push(b64, bio); BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL); int bioWriteRet = BIO_write(bio, src.c_str(), src.length()); - if (bioWriteRet < 0 || (size_t)bioWriteRet != src.length()) { + if (bioWriteRet < 0 || static_cast(bioWriteRet) != src.length()) { BIO_free_all(bio); throw std::runtime_error("BIO_write failed to write all data to memory buffer"); } diff --git a/pdns/test-base64_cc.cc b/pdns/test-base64_cc.cc index 01cae80d4d..b09611b425 100644 --- a/pdns/test-base64_cc.cc +++ b/pdns/test-base64_cc.cc @@ -8,6 +8,7 @@ #include #include "base64.hh" +#include "openssl/conf.h" using namespace boost; @@ -80,7 +81,13 @@ BOOST_AUTO_TEST_CASE(test_Base64_Decode_Garbage) { const std::string paddingOnly("===="); std::string decoded; - BOOST_CHECK_EQUAL(B64Decode(paddingOnly, decoded), -1); + auto ret = B64Decode(paddingOnly, decoded); +#if OPENSSL_VERSION_NUMBER >= 0x30500000 + BOOST_CHECK_EQUAL(ret, -1); +#else + // does not test anything meaningful, but avoids a "ret unused" warning + BOOST_CHECK(ret == 0 || ret == -1); +#endif } BOOST_AUTO_TEST_SUITE_END()