Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Langley <agl@chromium.org>2014-06-20 23:00:00 +0400
committerAdam Langley <agl@chromium.org>2014-06-21 00:17:37 +0400
commit01797e309fa3921447d16ae8822cba360116e4c8 (patch)
tree3c8aabeb68face6783dfd620c4439510fcdaeb77 /crypto/mem.c
parentaed2306b9db35f2ad06cd47b5afecfde08168a75 (diff)
psk_client_callback, 128-byte id bug.
Fix a bug in handling of 128 byte long PSK identity in psk_client_callback. OpenSSL supports PSK identities of up to (and including) 128 bytes in length. PSK identity is obtained via the psk_client_callback, implementors of which are expected to provide a NULL-terminated identity. However, the callback is invoked with only 128 bytes of storage thus making it impossible to return a 128 byte long identity and the required additional NULL byte. This CL fixes the issue by passing in a 129 byte long buffer into the psk_client_callback. As a safety precaution, this CL also zeroes out the buffer before passing it into the callback, uses strnlen for obtaining the length of the identity returned by the callback, and aborts the handshake if the identity (without the NULL terminator) is longer than 128 bytes.
Diffstat (limited to 'crypto/mem.c')
-rw-r--r--crypto/mem.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/crypto/mem.c b/crypto/mem.c
index 8a8482c8..c2fd5fc7 100644
--- a/crypto/mem.c
+++ b/crypto/mem.c
@@ -123,6 +123,18 @@ uint32_t OPENSSL_hash32(const void *ptr, size_t len) {
char *OPENSSL_strdup(const char *s) { return strdup(s); }
+size_t OPENSSL_strnlen(const char *s, size_t len) {
+ size_t i;
+
+ for (i = 0; i < len; i++) {
+ if (s[i] == 0) {
+ return i;
+ }
+ }
+
+ return len;
+}
+
int BIO_snprintf(char *buf, size_t n, const char *format, ...) {
va_list args;
int ret;