| OLD | NEW |
| 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 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 intptr_t SSLFilter::ProcessWriteEncryptedBuffer(int start, int end) { | 935 intptr_t SSLFilter::ProcessWriteEncryptedBuffer(int start, int end) { |
| 936 int length = end - start; | 936 int length = end - start; |
| 937 int bytes_processed = 0; | 937 int bytes_processed = 0; |
| 938 if (length > 0) { | 938 if (length > 0) { |
| 939 uint8_t* buffer = buffers_[kWriteEncrypted]; | 939 uint8_t* buffer = buffers_[kWriteEncrypted]; |
| 940 const uint8_t* buf1; | 940 const uint8_t* buf1; |
| 941 const uint8_t* buf2; | 941 const uint8_t* buf2; |
| 942 unsigned int len1; | 942 unsigned int len1; |
| 943 unsigned int len2; | 943 unsigned int len2; |
| 944 memio_Private* secret = memio_GetSecret(filter_); | 944 memio_Private* secret = memio_GetSecret(filter_); |
| 945 memio_GetWriteParams(secret, &buf1, &len1, &buf2, &len2); | 945 int status = memio_GetWriteParams(secret, &buf1, &len1, &buf2, &len2); |
| 946 if (status != 0) { |
| 947 return -1; |
| 948 } |
| 946 int bytes_to_send = | 949 int bytes_to_send = |
| 947 dart::Utils::Minimum(len1, static_cast<unsigned>(length)); | 950 dart::Utils::Minimum(len1, static_cast<unsigned>(length)); |
| 948 if (bytes_to_send > 0) { | 951 if (bytes_to_send > 0) { |
| 949 memmove(buffer + start, buf1, bytes_to_send); | 952 memmove(buffer + start, buf1, bytes_to_send); |
| 950 bytes_processed = bytes_to_send; | 953 bytes_processed = bytes_to_send; |
| 951 } | 954 } |
| 952 bytes_to_send = dart::Utils::Minimum(len2, | 955 bytes_to_send = dart::Utils::Minimum(len2, |
| 953 static_cast<unsigned>(length - bytes_processed)); | 956 static_cast<unsigned>(length - bytes_processed)); |
| 954 if (bytes_to_send > 0) { | 957 if (bytes_to_send > 0) { |
| 955 memmove(buffer + start + bytes_processed, buf2, bytes_to_send); | 958 memmove(buffer + start + bytes_processed, buf2, bytes_to_send); |
| 956 bytes_processed += bytes_to_send; | 959 bytes_processed += bytes_to_send; |
| 957 } | 960 } |
| 958 if (bytes_processed > 0) { | 961 if (bytes_processed > 0) { |
| 959 memio_PutWriteResult(secret, bytes_processed); | 962 memio_PutWriteResult(secret, bytes_processed); |
| 960 } | 963 } |
| 961 } | 964 } |
| 962 return bytes_processed; | 965 return bytes_processed; |
| 963 } | 966 } |
| 964 | 967 |
| 965 } // namespace bin | 968 } // namespace bin |
| 966 } // namespace dart | 969 } // namespace dart |
| OLD | NEW |