From 159ccced6564970e2b2f8d95a7836ee17446e719 Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Tue, 8 Dec 2020 12:19:12 +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 91723b65b..ce2e459a0 100644 --- a/lib/base/tlsutility.cpp +++ b/lib/base/tlsutility.cpp @@ -899,19 +899,4 @@ Array::Ptr GetSubjectAltNames(const std::shared_ptr& cert) return sans; } -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 a923311d0..665f4e794 100644 --- a/lib/base/tlsutility.hpp +++ b/lib/base/tlsutility.hpp @@ -62,8 +62,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 */