From 64a49ee3a16f16c4ca7f685a95db97ffafe502b5 Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Wed, 9 Dec 2020 12:22:52 +0100 Subject: [PATCH] Remove std::string to_string(const errinfo_openssl_error& e) The function was never used and it's implementation contains a bug where a buffer of too small size is used as a paramter to ERR_error_string. According to the `man 3 ERR_error_info`, the buffer has to be at least 256 bytes in size. Also the function seems of limited use as it allows to output the tag object used with additional error information for exceptions in Boost. However, you boost::get_error_info<>() just returns the value type but not the full tag object from the exception. --- lib/base/tlsutility.cpp | 15 --------------- lib/base/tlsutility.hpp | 2 -- 2 files changed, 17 deletions(-) diff --git a/lib/base/tlsutility.cpp b/lib/base/tlsutility.cpp index 3c6751002..498feed7a 100644 --- a/lib/base/tlsutility.cpp +++ b/lib/base/tlsutility.cpp @@ -809,19 +809,4 @@ bool VerifyCertificate(const std::shared_ptr& caCertificate, const std::sh return rc == 1; } -std::string to_string(const errinfo_openssl_error& e) -{ - std::ostringstream tmp; - int code = e.value(); - char errbuf[120]; - - const char *message = ERR_error_string(code, errbuf); - - if (!message) - message = "Unknown error."; - - tmp << code << ", \"" << message << "\""; - return "[errinfo_openssl_error]" + tmp.str() + "\n"; -} - } diff --git a/lib/base/tlsutility.hpp b/lib/base/tlsutility.hpp index de7033311..ac4e642b6 100644 --- a/lib/base/tlsutility.hpp +++ b/lib/base/tlsutility.hpp @@ -52,8 +52,6 @@ class openssl_error : virtual public std::exception, virtual public boost::excep struct errinfo_openssl_error_; typedef boost::error_info errinfo_openssl_error; -std::string to_string(const errinfo_openssl_error& e); - } #endif /* TLSUTILITY_H */