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

Side by Side Diff: runtime/bin/secure_socket_utils.cc

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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 | « runtime/bin/secure_socket_utils.h ('k') | runtime/bin/security_context.h » ('j') | 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 "bin/secure_socket_utils.h" 7 #include "bin/secure_socket_utils.h"
8 8
9 #include <openssl/err.h> 9 #include <openssl/err.h>
10 #include <openssl/ssl.h> 10 #include <openssl/ssl.h>
(...skipping 27 matching lines...) Expand all
38 text_buffer->Printf(": %s", X509_verify_cert_error_string(result)); 38 text_buffer->Printf(": %s", X509_verify_cert_error_string(result));
39 } 39 }
40 if ((path != NULL) && (line >= 0)) { 40 if ((path != NULL) && (line >= 0)) {
41 const char* file = strrchr(path, sep[0]); 41 const char* file = strrchr(path, sep[0]);
42 path = file ? file + 1 : path; 42 path = file ? file + 1 : path;
43 text_buffer->Printf("(%s:%d)", path, line); 43 text_buffer->Printf("(%s:%d)", path, line);
44 } 44 }
45 } 45 }
46 } 46 }
47 47
48
49 // Handle an error reported from the BoringSSL library. 48 // Handle an error reported from the BoringSSL library.
50 void SecureSocketUtils::ThrowIOException(int status, 49 void SecureSocketUtils::ThrowIOException(int status,
51 const char* exception_type, 50 const char* exception_type,
52 const char* message, 51 const char* message,
53 const SSL* ssl) { 52 const SSL* ssl) {
54 Dart_Handle exception; 53 Dart_Handle exception;
55 { 54 {
56 TextBuffer error_string(SSL_ERROR_MESSAGE_BUFFER_SIZE); 55 TextBuffer error_string(SSL_ERROR_MESSAGE_BUFFER_SIZE);
57 SecureSocketUtils::FetchErrorString(ssl, &error_string); 56 SecureSocketUtils::FetchErrorString(ssl, &error_string);
58 OSError os_error_struct(status, error_string.buf(), OSError::kBoringSSL); 57 OSError os_error_struct(status, error_string.buf(), OSError::kBoringSSL);
59 Dart_Handle os_error = DartUtils::NewDartOSError(&os_error_struct); 58 Dart_Handle os_error = DartUtils::NewDartOSError(&os_error_struct);
60 exception = 59 exception =
61 DartUtils::NewDartIOException(exception_type, message, os_error); 60 DartUtils::NewDartIOException(exception_type, message, os_error);
62 ASSERT(!Dart_IsError(exception)); 61 ASSERT(!Dart_IsError(exception));
63 } 62 }
64 Dart_ThrowException(exception); 63 Dart_ThrowException(exception);
65 UNREACHABLE(); 64 UNREACHABLE();
66 } 65 }
67 66
68
69 void SecureSocketUtils::CheckStatusSSL(int status, 67 void SecureSocketUtils::CheckStatusSSL(int status,
70 const char* type, 68 const char* type,
71 const char* message, 69 const char* message,
72 const SSL* ssl) { 70 const SSL* ssl) {
73 // TODO(24183): Take appropriate action on failed calls, 71 // TODO(24183): Take appropriate action on failed calls,
74 // throw exception that includes all messages from the error stack. 72 // throw exception that includes all messages from the error stack.
75 if (status == 1) { 73 if (status == 1) {
76 return; 74 return;
77 } 75 }
78 if (SSL_LOG_STATUS) { 76 if (SSL_LOG_STATUS) {
79 int error = ERR_get_error(); 77 int error = ERR_get_error();
80 Log::PrintErr("Failed: %s status %d", message, status); 78 Log::PrintErr("Failed: %s status %d", message, status);
81 char error_string[SSL_ERROR_MESSAGE_BUFFER_SIZE]; 79 char error_string[SSL_ERROR_MESSAGE_BUFFER_SIZE];
82 ERR_error_string_n(error, error_string, SSL_ERROR_MESSAGE_BUFFER_SIZE); 80 ERR_error_string_n(error, error_string, SSL_ERROR_MESSAGE_BUFFER_SIZE);
83 Log::PrintErr("ERROR: %d %s\n", error, error_string); 81 Log::PrintErr("ERROR: %d %s\n", error, error_string);
84 } 82 }
85 SecureSocketUtils::ThrowIOException(status, type, message, ssl); 83 SecureSocketUtils::ThrowIOException(status, type, message, ssl);
86 } 84 }
87 85
88
89 void SecureSocketUtils::CheckStatus(int status, 86 void SecureSocketUtils::CheckStatus(int status,
90 const char* type, 87 const char* type,
91 const char* message) { 88 const char* message) {
92 SecureSocketUtils::CheckStatusSSL(status, type, message, NULL); 89 SecureSocketUtils::CheckStatusSSL(status, type, message, NULL);
93 } 90 }
94 91
95 } // namespace bin 92 } // namespace bin
96 } // namespace dart 93 } // namespace dart
97 94
98 #endif // !defined(DART_IO_DISABLED) && 95 #endif // !defined(DART_IO_DISABLED) &&
99 // !defined(DART_IO_SECURE_SOCKET_DISABLED) 96 // !defined(DART_IO_SECURE_SOCKET_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/secure_socket_utils.h ('k') | runtime/bin/security_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698