changeset 20412:420eb4b4e1f5

istream-decrypt: Correctly check the header length for v1
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Mon, 27 Jun 2016 13:19:35 +0300
parents 339842104272
children 6a509c06684d
files src/lib-dcrypt/istream-decrypt.c
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-dcrypt/istream-decrypt.c	Fri Jun 24 12:14:32 2016 +0300
+++ b/src/lib-dcrypt/istream-decrypt.c	Mon Jun 27 13:19:35 2016 +0300
@@ -70,7 +70,8 @@
 	buffer_t *key = buffer_create_dynamic(pool_datastack_create(), 256);
 
 	hdr_len = ((data[0] << 8) | data[1]) + 12;
-	if (mlen < hdr_len) {
+
+	if (mlen < hdr_len - pos) {
 		/* try to read more */
 		return 0;
 	}