Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Unified Diff: runtime/bin/secure_socket_boringssl.cc

Issue 2812623005: [dart:io] Fix crash in fetching the error message from BoringSSL (Closed)
Patch Set: Formatting Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/secure_socket_boringssl.cc
diff --git a/runtime/bin/secure_socket_boringssl.cc b/runtime/bin/secure_socket_boringssl.cc
index f2df95d0a787ca3d5be355d4fc3eb4f653a051c0..a3740a84a3af54282e6afd402d4af37a05661bf2 100644
--- a/runtime/bin/secure_socket_boringssl.cc
+++ b/runtime/bin/secure_socket_boringssl.cc
@@ -83,24 +83,26 @@ const char* commandline_root_certs_cache = NULL;
// Get the error messages from BoringSSL, and put them in buffer as a
// null-terminated string.
static void FetchErrorString(const SSL* ssl, TextBuffer* text_buffer) {
- uint32_t error = 0;
- const char* path = NULL;
- int line = -1;
const char* sep = File::PathSeparator();
- do {
- error = ERR_get_error_line(&path, &line);
- const char* file = strrchr(path, sep[0]);
- path = file ? file + 1 : path;
+ while (true) {
+ const char* path = NULL;
+ int line = -1;
+ uint32_t error = ERR_get_error_line(&path, &line);
+ if (error == 0) {
+ break;
+ }
+ text_buffer->Printf("\n\t%s", ERR_reason_error_string(error));
if ((ssl != NULL) && (ERR_GET_LIB(error) == ERR_LIB_SSL) &&
(ERR_GET_REASON(error) == SSL_R_CERTIFICATE_VERIFY_FAILED)) {
intptr_t result = SSL_get_verify_result(ssl);
- text_buffer->Printf("\n\t%s: %s (%s:%d)", ERR_reason_error_string(error),
- X509_verify_cert_error_string(result), path, line);
- } else if (error != 0) {
- text_buffer->Printf("\n\t%s (%s:%d)", ERR_reason_error_string(error),
- path, line);
+ text_buffer->Printf(": %s", X509_verify_cert_error_string(result));
}
- } while (error != 0);
+ if ((path != NULL) && (line >= 0)) {
+ const char* file = strrchr(path, sep[0]);
+ path = file ? file + 1 : path;
+ text_buffer->Printf("(%s:%d)", path, line);
+ }
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698