From: David Benjamin Date: Mon, 2 Jun 2014 17:55:20 +0000 (+0100) Subject: Check there is enough room for extension. X-Git-Tag: OpenSSL_1_0_2-beta2~174 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=56b94a38b9a2197210a110c4a01a39ac75b34ce8;p=oweals%2Fopenssl.git Check there is enough room for extension. (cherry picked from commit 7d89b3bf42e4b4067371ab33ef7631434e41d1e4) --- diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index 07674405d8..eefe93ed13 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -1380,6 +1380,8 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *p, unsigned cha #ifndef OPENSSL_NO_HEARTBEATS /* Add Heartbeat extension */ + if ((limit - ret - 4 - 1) < 0) + return NULL; s2n(TLSEXT_TYPE_heartbeat,ret); s2n(1,ret); /* Set mode: @@ -1658,6 +1660,8 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *p, unsigned cha /* Add Heartbeat extension if we've received one */ if (s->tlsext_heartbeat & SSL_TLSEXT_HB_ENABLED) { + if ((limit - ret - 4 - 1) < 0) + return NULL; s2n(TLSEXT_TYPE_heartbeat,ret); s2n(1,ret); /* Set mode: