Blame SOURCES/Fix-length-checks-in-parallel-driver.patch

083b3c
From 64544c7f4ed72b3023955ebe6ad3b118ebb8d6c7 Mon Sep 17 00:00:00 2001
083b3c
From: akallabeth <akallabeth@posteo.net>
083b3c
Date: Thu, 6 Oct 2022 09:12:40 +0200
083b3c
Subject: [PATCH] Fix length checks in parallel driver
083b3c
083b3c
The length requested was not checked against the length read from
083b3c
the port.
083b3c
083b3c
(cherry picked from commit 094cc5a4596c299595b732effd59ee149181fd61)
083b3c
---
083b3c
 channels/parallel/client/parallel_main.c | 3 ++-
083b3c
 1 file changed, 2 insertions(+), 1 deletion(-)
083b3c
083b3c
diff --git a/channels/parallel/client/parallel_main.c b/channels/parallel/client/parallel_main.c
083b3c
index af3e82703..993605a65 100644
083b3c
--- a/channels/parallel/client/parallel_main.c
083b3c
+++ b/channels/parallel/client/parallel_main.c
083b3c
@@ -159,7 +159,7 @@ static UINT parallel_process_irp_read(PARALLEL_DEVICE* parallel, IRP* irp)
083b3c
 		return ERROR_INVALID_DATA;
083b3c
 	Stream_Read_UINT32(irp->input, Length);
083b3c
 	Stream_Read_UINT64(irp->input, Offset);
083b3c
-	buffer = (BYTE*)malloc(Length);
083b3c
+	buffer = (BYTE*)calloc(Length, sizeof(BYTE));
083b3c
 
083b3c
 	if (!buffer)
083b3c
 	{
083b3c
@@ -178,6 +178,7 @@ static UINT parallel_process_irp_read(PARALLEL_DEVICE* parallel, IRP* irp)
083b3c
 	}
083b3c
 	else
083b3c
 	{
083b3c
+		Length = status;
083b3c
 	}
083b3c
 
083b3c
 	Stream_Write_UINT32(irp->output, Length);
083b3c
-- 
083b3c
2.37.1
083b3c