summaryrefslogtreecommitdiff
path: root/lib/cipher.c
diff options
context:
space:
mode:
authorDaiki Ueno <dueno@redhat.com>2018-06-08 12:51:40 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2018-06-12 13:01:17 +0000
commit4c7193cf97e9796a95d40b46dd045b14c707fd4d (patch)
tree885b410666fbeaf5e90480924863f14a17bb8305 /lib/cipher.c
parentc48e8d25d2d378f6b258de05e3e80fed19d788fa (diff)
downloadgnutls-4c7193cf97e9796a95d40b46dd045b14c707fd4d.tar.gz
record: fix padding removal when the payload is zero-length
Previoysly if TLSInnerPlaintext.content is zero-length, the loop couldn't detect ContentType following the content. Signed-off-by: Daiki Ueno <dueno@redhat.com>
Diffstat (limited to 'lib/cipher.c')
-rw-r--r--lib/cipher.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/cipher.c b/lib/cipher.c
index c8bdeb5428..2bfae68552 100644
--- a/lib/cipher.c
+++ b/lib/cipher.c
@@ -855,10 +855,10 @@ decrypt_packet_tls13(gnutls_session_t session,
/* now figure the actual data size. We intentionally iterate through all data,
* to avoid leaking the padding length due to timing differences in processing.
*/
- for (j=length-1;j>0;j--) {
- if (plain->data[j]!=0 && length_set == 0) {
- *type = plain->data[j];
- length = j;
+ for (j=length;j>0;j--) {
+ if (plain->data[j-1]!=0 && length_set == 0) {
+ *type = plain->data[j-1];
+ length = j-1;
length_set = 1;
}
}