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

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

Issue 1383713002: Free copy of hostname in SecureSocket implementation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 #include "bin/secure_socket.h" 5 #include "bin/secure_socket.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 } else { 892 } else {
893 SetAlpnProtocolList(protocols_handle, ssl_, NULL, false); 893 SetAlpnProtocolList(protocols_handle, ssl_, NULL, false);
894 // Sets the hostname in the certificate-checking object, so it is checked 894 // Sets the hostname in the certificate-checking object, so it is checked
895 // against the certificate presented by the server. 895 // against the certificate presented by the server.
896 X509_VERIFY_PARAM* certificate_checking_parameters = SSL_get0_param(ssl_); 896 X509_VERIFY_PARAM* certificate_checking_parameters = SSL_get0_param(ssl_);
897 hostname_ = strdup(hostname); 897 hostname_ = strdup(hostname);
898 X509_VERIFY_PARAM_set_flags(certificate_checking_parameters, 898 X509_VERIFY_PARAM_set_flags(certificate_checking_parameters,
899 X509_V_FLAG_PARTIAL_CHAIN | 899 X509_V_FLAG_PARTIAL_CHAIN |
900 X509_V_FLAG_TRUSTED_FIRST); 900 X509_V_FLAG_TRUSTED_FIRST);
901 X509_VERIFY_PARAM_set_hostflags(certificate_checking_parameters, 0); 901 X509_VERIFY_PARAM_set_hostflags(certificate_checking_parameters, 0);
902 X509_VERIFY_PARAM_set1_host(certificate_checking_parameters, 902 status = X509_VERIFY_PARAM_set1_host(certificate_checking_parameters,
903 hostname_, strlen(hostname_)); 903 hostname_, strlen(hostname_));
904 // TODO(24225) Check return value of set1_host(). 904 CheckStatus(status, "Set hostname for certificate checking", __LINE__);
905 // TODO(24186) free hostname_ if it is not freed when SSL is destroyed.
906 // otherwise, make it a local variable, not a instance field.
907 } 905 }
908 // Make the connection: 906 // Make the connection:
909 if (is_server_) { 907 if (is_server_) {
910 status = SSL_accept(ssl_); 908 status = SSL_accept(ssl_);
911 if (SSL_LOG_STATUS) Log::Print("SSL_accept status: %d\n", status); 909 if (SSL_LOG_STATUS) Log::Print("SSL_accept status: %d\n", status);
912 if (status != 1) { 910 if (status != 1) {
913 // TODO(whesse): expect a needs-data error here. Handle other errors. 911 // TODO(whesse): expect a needs-data error here. Handle other errors.
914 error = SSL_get_error(ssl_, status); 912 error = SSL_get_error(ssl_, status);
915 if (SSL_LOG_STATUS) Log::Print("SSL_accept error: %d\n", error); 913 if (SSL_LOG_STATUS) Log::Print("SSL_accept error: %d\n", error);
916 } 914 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 1035
1038 void SSLFilter::Destroy() { 1036 void SSLFilter::Destroy() {
1039 if (ssl_ != NULL) { 1037 if (ssl_ != NULL) {
1040 SSL_free(ssl_); 1038 SSL_free(ssl_);
1041 ssl_ = NULL; 1039 ssl_ = NULL;
1042 } 1040 }
1043 if (socket_side_ != NULL) { 1041 if (socket_side_ != NULL) {
1044 BIO_free(socket_side_); 1042 BIO_free(socket_side_);
1045 socket_side_ = NULL; 1043 socket_side_ = NULL;
1046 } 1044 }
1045 if (hostname_ != NULL) {
1046 free(hostname_);
1047 hostname_ = NULL;
1048 }
1047 for (int i = 0; i < kNumBuffers; ++i) { 1049 for (int i = 0; i < kNumBuffers; ++i) {
1048 Dart_DeletePersistentHandle(dart_buffer_objects_[i]); 1050 Dart_DeletePersistentHandle(dart_buffer_objects_[i]);
1049 delete[] buffers_[i]; 1051 delete[] buffers_[i];
1050 } 1052 }
1051 Dart_DeletePersistentHandle(string_start_); 1053 Dart_DeletePersistentHandle(string_start_);
1052 Dart_DeletePersistentHandle(string_length_); 1054 Dart_DeletePersistentHandle(string_length_);
1053 Dart_DeletePersistentHandle(handshake_complete_); 1055 Dart_DeletePersistentHandle(handshake_complete_);
1054 Dart_DeletePersistentHandle(bad_certificate_callback_); 1056 Dart_DeletePersistentHandle(bad_certificate_callback_);
1055 } 1057 }
1056 1058
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 } else { 1128 } else {
1127 if (SSL_LOG_DATA) Log::Print( 1129 if (SSL_LOG_DATA) Log::Print(
1128 "WriteEncrypted BIO_read wrote %d bytes\n", bytes_processed); 1130 "WriteEncrypted BIO_read wrote %d bytes\n", bytes_processed);
1129 } 1131 }
1130 } 1132 }
1131 return bytes_processed; 1133 return bytes_processed;
1132 } 1134 }
1133 1135
1134 } // namespace bin 1136 } // namespace bin
1135 } // namespace dart 1137 } // namespace dart
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