Blob Blame History Raw
From 211f398a262298286029df78530a42fae0c7390d Mon Sep 17 00:00:00 2001
From: Isaac Boukris <iboukris@gmail.com>
Date: Thu, 21 Nov 2019 15:13:19 +0100
Subject: [PATCH 186/187] sess_crypt_blob can only crypt blobs whose size
 divides by 8

Signed-off-by: Isaac Boukris <iboukris@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit b5d8f1f78a04719c6a5d15aa92ae398be326fe56)
---
 libcli/auth/session.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libcli/auth/session.c b/libcli/auth/session.c
index 4af70d361af..43ce9d54fdc 100644
--- a/libcli/auth/session.c
+++ b/libcli/auth/session.c
@@ -34,13 +34,16 @@ int sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *sessio
 {
 	int i, k, rc;
 
+	if (in->length % 8 != 0) {
+		return GNUTLS_E_INVALID_REQUEST;
+	}
+
 	for (i=0,k=0;
 	     i<in->length;
 	     i += 8, k += 7) {
 		uint8_t bin[8], bout[8], key[7];
 
-		memset(bin, 0, 8);
-		memcpy(bin,  &in->data[i], MIN(8, in->length-i));
+		memcpy(bin,  &in->data[i], 8);
 
 		if (k + 7 > session_key->length) {
 			k = (session_key->length - k);
@@ -52,7 +55,7 @@ int sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *sessio
 			return rc;
 		}
 
-		memcpy(&out->data[i], bout, MIN(8, in->length-i));
+		memcpy(&out->data[i], bout, 8);
 	}
 	return 0;
 }
-- 
2.23.0