From: Adam Langley Date: Mon, 8 Aug 2016 20:36:55 +0000 (-0700) Subject: Fix test of first of 255 CBC padding bytes. X-Git-Tag: OpenSSL_1_1_0~242 X-Git-Url: https://git.openssl.org/?p=openssl.git;a=commitdiff_plain;h=eea8723cd0d56398fc40d0337e9e730961c9c2fa Fix test of first of 255 CBC padding bytes. Thanks to Peter Gijsels for pointing out that if a CBC record has 255 bytes of padding, the first was not being checked. (This is an import of change 80842bdb from BoringSSL.) Reviewed-by: Emilia Käsper Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/1431) --- diff --git a/ssl/record/ssl3_record.c b/ssl/record/ssl3_record.c index ad240bc52d..49c6756376 100644 --- a/ssl/record/ssl3_record.c +++ b/ssl/record/ssl3_record.c @@ -1149,9 +1149,9 @@ int tls1_cbc_remove_padding(const SSL *s, * maximum amount of padding possible. (Again, the length of the record * is public information so we can use it.) */ - to_check = 255; /* maximum amount of padding. */ - if (to_check > rec->length - 1) - to_check = rec->length - 1; + to_check = 256; /* maximum amount of padding, inc length byte. */ + if (to_check > rec->length) + to_check = rec->length; for (i = 0; i < to_check; i++) { unsigned char mask = constant_time_ge_8(padding_length, i);