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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED) 5 #if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(HOST_OS_ANDROID) || defined(HOST_OS_LINUX) || \ 8 #if defined(HOST_OS_ANDROID) || defined(HOST_OS_LINUX) || \
9 defined(HOST_OS_WINDOWS) || defined(HOST_OS_FUCHSIA) 9 defined(HOST_OS_WINDOWS) || defined(HOST_OS_FUCHSIA)
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 static const bool SSL_LOG_DATA = false; 76 static const bool SSL_LOG_DATA = false;
77 77
78 static const int SSL_ERROR_MESSAGE_BUFFER_SIZE = 1000; 78 static const int SSL_ERROR_MESSAGE_BUFFER_SIZE = 1000;
79 79
80 const char* commandline_root_certs_file = NULL; 80 const char* commandline_root_certs_file = NULL;
81 const char* commandline_root_certs_cache = NULL; 81 const char* commandline_root_certs_cache = NULL;
82 82
83 // Get the error messages from BoringSSL, and put them in buffer as a 83 // Get the error messages from BoringSSL, and put them in buffer as a
84 // null-terminated string. 84 // null-terminated string.
85 static void FetchErrorString(const SSL* ssl, TextBuffer* text_buffer) { 85 static void FetchErrorString(const SSL* ssl, TextBuffer* text_buffer) {
86 uint32_t error = 0;
87 const char* path = NULL;
88 int line = -1;
89 const char* sep = File::PathSeparator(); 86 const char* sep = File::PathSeparator();
90 do { 87 while (true) {
91 error = ERR_get_error_line(&path, &line); 88 const char* path = NULL;
92 const char* file = strrchr(path, sep[0]); 89 int line = -1;
93 path = file ? file + 1 : path; 90 uint32_t error = ERR_get_error_line(&path, &line);
91 if (error == 0) {
92 break;
93 }
94 text_buffer->Printf("\n\t%s", ERR_reason_error_string(error));
94 if ((ssl != NULL) && (ERR_GET_LIB(error) == ERR_LIB_SSL) && 95 if ((ssl != NULL) && (ERR_GET_LIB(error) == ERR_LIB_SSL) &&
95 (ERR_GET_REASON(error) == SSL_R_CERTIFICATE_VERIFY_FAILED)) { 96 (ERR_GET_REASON(error) == SSL_R_CERTIFICATE_VERIFY_FAILED)) {
96 intptr_t result = SSL_get_verify_result(ssl); 97 intptr_t result = SSL_get_verify_result(ssl);
97 text_buffer->Printf("\n\t%s: %s (%s:%d)", ERR_reason_error_string(error), 98 text_buffer->Printf(": %s", X509_verify_cert_error_string(result));
98 X509_verify_cert_error_string(result), path, line);
99 } else if (error != 0) {
100 text_buffer->Printf("\n\t%s (%s:%d)", ERR_reason_error_string(error),
101 path, line);
102 } 99 }
103 } while (error != 0); 100 if ((path != NULL) && (line >= 0)) {
101 const char* file = strrchr(path, sep[0]);
102 path = file ? file + 1 : path;
103 text_buffer->Printf("(%s:%d)", path, line);
104 }
105 }
104 } 106 }
105 107
106 108
107 // Handle an error reported from the BoringSSL library. 109 // Handle an error reported from the BoringSSL library.
108 static void ThrowIOException(int status, 110 static void ThrowIOException(int status,
109 const char* exception_type, 111 const char* exception_type,
110 const char* message, 112 const char* message,
111 const SSL* ssl) { 113 const SSL* ssl) {
112 Dart_Handle exception; 114 Dart_Handle exception;
113 { 115 {
(...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 return bytes_processed; 1798 return bytes_processed;
1797 } 1799 }
1798 1800
1799 } // namespace bin 1801 } // namespace bin
1800 } // namespace dart 1802 } // namespace dart
1801 1803
1802 #endif // defined(HOST_OS_LINUX) 1804 #endif // defined(HOST_OS_LINUX)
1803 1805
1804 #endif // !defined(DART_IO_DISABLED) && 1806 #endif // !defined(DART_IO_DISABLED) &&
1805 // !defined(DART_IO_SECURE_SOCKET_DISABLED) 1807 // !defined(DART_IO_SECURE_SOCKET_DISABLED)
OLDNEW
« 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