Index: runtime/bin/secure_socket.cc |
diff --git a/runtime/bin/secure_socket.cc b/runtime/bin/secure_socket.cc |
index f2eaef96a270b51d93d9b35b8d29f5e9dad0627d..1b820083955438e0e704cd216cfa1de745a3496d 100644 |
--- a/runtime/bin/secure_socket.cc |
+++ b/runtime/bin/secure_socket.cc |
@@ -54,7 +54,7 @@ static void ThrowIOException(int status, |
error_string[0] = '\0'; |
int error = ERR_get_error(); |
while (error != 0) { |
- int length = strnlen(error_string, SSL_ERROR_MESSAGE_BUFFER_SIZE); |
+ int length = strlen(error_string); |
int free_length = SSL_ERROR_MESSAGE_BUFFER_SIZE - length; |
if (free_length > 16) { |
// Enough room for error code at least. |
@@ -65,6 +65,7 @@ static void ThrowIOException(int status, |
free_length--; |
} |
ERR_error_string_n(error, error_string + length, free_length); |
+ // ERR_error_string_n is guaranteed to leave a null-terminated string. |
} |
error = ERR_get_error(); |
} |