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

Side by Side Diff: runtime/bin/secure_socket_boringssl.h

Issue 2206233003: Fix memory leaks in BoringSSL secure socket implementation (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add comments Created 4 years, 4 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 | runtime/bin/secure_socket_boringssl.cc » ('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) 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 #ifndef BIN_SECURE_SOCKET_BORINGSSL_H_ 5 #ifndef BIN_SECURE_SOCKET_BORINGSSL_H_
6 #define BIN_SECURE_SOCKET_BORINGSSL_H_ 6 #define BIN_SECURE_SOCKET_BORINGSSL_H_
7 7
8 #if !defined(BIN_SECURE_SOCKET_H_) 8 #if !defined(BIN_SECURE_SOCKET_H_)
9 #error Do not include secure_socket_boringssl.h directly. Use secure_socket.h. 9 #error Do not include secure_socket_boringssl.h directly. Use secure_socket.h.
10 #endif 10 #endif
(...skipping 15 matching lines...) Expand all
26 #include "bin/thread.h" 26 #include "bin/thread.h"
27 #include "bin/utils.h" 27 #include "bin/utils.h"
28 28
29 namespace dart { 29 namespace dart {
30 namespace bin { 30 namespace bin {
31 31
32 /* These are defined in root_certificates.cc. */ 32 /* These are defined in root_certificates.cc. */
33 extern const unsigned char* root_certificates_pem; 33 extern const unsigned char* root_certificates_pem;
34 extern unsigned int root_certificates_pem_length; 34 extern unsigned int root_certificates_pem_length;
35 35
36 class SSLContext {
37 public:
38 explicit SSLContext(SSL_CTX* context) :
39 context_(context),
40 alpn_protocol_string_(NULL) {
41 }
42
43 ~SSLContext() {
44 SSL_CTX_free(context_);
45 if (alpn_protocol_string_ != NULL) {
46 free(alpn_protocol_string_);
47 }
48 }
49
50 SSL_CTX* context() const { return context_; }
51
52 uint8_t* alpn_protocol_string() const { return alpn_protocol_string_; }
53 void set_alpn_protocol_string(uint8_t* protocol_string) {
54 if (alpn_protocol_string_ != NULL) {
55 free(alpn_protocol_string_);
56 }
57 alpn_protocol_string_ = protocol_string;
58 }
59
60 private:
61 SSL_CTX* context_;
62 uint8_t* alpn_protocol_string_;
63
64 DISALLOW_COPY_AND_ASSIGN(SSLContext);
65 };
66
36 /* 67 /*
37 * SSLFilter encapsulates the NSS SSL(TLS) code in a filter, that communicates 68 * SSLFilter encapsulates the SSL(TLS) code in a filter, that communicates
38 * with the containing _SecureFilterImpl Dart object through four shared 69 * with the containing _SecureFilterImpl Dart object through four shared
39 * ExternalByteArray buffers, for reading and writing plaintext, and 70 * ExternalByteArray buffers, for reading and writing plaintext, and
40 * reading and writing encrypted text. The filter handles handshaking 71 * reading and writing encrypted text. The filter handles handshaking
41 * and certificate verification. 72 * and certificate verification.
42 */ 73 */
43 class SSLFilter : public ReferenceCounted<SSLFilter> { 74 class SSLFilter : public ReferenceCounted<SSLFilter> {
44 public: 75 public:
45 // These enums must agree with those in sdk/lib/io/secure_socket.dart. 76 // These enums must agree with those in sdk/lib/io/secure_socket.dart.
46 enum BufferIndex { 77 enum BufferIndex {
47 kReadPlaintext, 78 kReadPlaintext,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 Dart_Handle InitializeBuffers(Dart_Handle dart_this); 156 Dart_Handle InitializeBuffers(Dart_Handle dart_this);
126 void InitializePlatformData(); 157 void InitializePlatformData();
127 158
128 DISALLOW_COPY_AND_ASSIGN(SSLFilter); 159 DISALLOW_COPY_AND_ASSIGN(SSLFilter);
129 }; 160 };
130 161
131 } // namespace bin 162 } // namespace bin
132 } // namespace dart 163 } // namespace dart
133 164
134 #endif // BIN_SECURE_SOCKET_BORINGSSL_H_ 165 #endif // BIN_SECURE_SOCKET_BORINGSSL_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/secure_socket_boringssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698