Make error size more explicit
authorSubodh Iyengar <subodh@fb.com>
Wed, 11 May 2016 07:14:01 +0000 (00:14 -0700)
committerFacebook Github Bot 9 <facebook-github-bot-9-bot@fb.com>
Wed, 11 May 2016 07:20:26 +0000 (00:20 -0700)
Summary:
We shouldn't rely on the internal buffer size of openssl
for errors.

This makes it more explicit.

Reviewed By: knekritz

Differential Revision: D3285918

fbshipit-source-id: 452bf16a3de151d0aa79c774f2fdfc1e08ee6f9c

folly/io/async/ssl/SSLErrors.cpp

index c34e8bbd7782695b9ea94ce2bb3d8b212969534c..ebc5d3d0fa456ac3bac115739375310b6a0e1ebe 100644 (file)
@@ -39,8 +39,8 @@ std::string decodeOpenSSLError(
     return "SSL connection closed normally";
   } else {
     std::array<char, 256> buf;
-    std::string msg(ERR_error_string(errError, buf.data()));
-    return msg;
+    ERR_error_string_n(errError, buf.data(), buf.size());
+    return std::string(buf.data(), buf.size());
   }
 }