freerdp: patch CVE-2024-32039

Details: https://nvd.nist.gov/vuln/detail/CVE-2024-32039

Pick the commit that is marked to resolve this vulerability, mentioned
by the Github advisory[1].

[1]: https://github.com/FreeRDP/FreeRDP/security/advisories/GHSA-q5h8-7j42-j4r9

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
This commit is contained in:
Gyorgy Sarvari
2026-01-22 06:43:55 +01:00
parent 86566fac39
commit cebeb9b1a6
2 changed files with 79 additions and 0 deletions
@@ -0,0 +1,78 @@
From 519c08d4720950dbeef8e671431ff8a6ea4e2927 Mon Sep 17 00:00:00 2001
From: akallabeth <akallabeth@posteo.net>
Date: Tue, 16 Apr 2024 08:35:05 +0200
Subject: [PATCH] fix integer overflow
reorder check to prevent possible integer overflow
(cherry picked from commit 3a2a241b8fcfee853e35cc54bec00375096fedd9)
CVE: CVE-2024-32039
Upstream-Status: Backport [https://github.com/FreeRDP/FreeRDP/commit/d88ad1acd142769650a6159906ac90f46a766265]
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
libfreerdp/codec/clear.c | 2 +-
libfreerdp/codec/zgfx.c | 16 +++++++++++-----
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/libfreerdp/codec/clear.c b/libfreerdp/codec/clear.c
index fadd98e67..0e169cf9d 100644
--- a/libfreerdp/codec/clear.c
+++ b/libfreerdp/codec/clear.c
@@ -410,7 +410,7 @@ static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear, wStream* s,
}
}
- if ((pixelIndex + runLengthFactor) > pixelCount)
+ if ((pixelIndex >= pixelCount) || (runLengthFactor > (pixelCount - pixelIndex)))
{
WLog_ERR(TAG,
"pixelIndex %" PRIu32 " + runLengthFactor %" PRIu32 " > pixelCount %" PRIu32
diff --git a/libfreerdp/codec/zgfx.c b/libfreerdp/codec/zgfx.c
index 4489b3798..3ed5067c8 100644
--- a/libfreerdp/codec/zgfx.c
+++ b/libfreerdp/codec/zgfx.c
@@ -23,6 +23,8 @@
#include "config.h"
#endif
+#include <assert.h>
+
#include <winpr/crt.h>
#include <winpr/print.h>
#include <winpr/bitstream.h>
@@ -230,7 +232,10 @@ static BOOL zgfx_decompress_segment(ZGFX_CONTEXT* zgfx, wStream* stream, size_t
BYTE* pbSegment;
size_t cbSegment;
- if (!zgfx || !stream || (segmentSize < 2))
+ assert((zgfx) && "Assert failed: zgfx");
+ assert((stream) && "Assert failed: stream");
+
+ if (segmentSize < 2)
return FALSE;
cbSegment = segmentSize - 1;
@@ -349,8 +354,9 @@ static BOOL zgfx_decompress_segment(ZGFX_CONTEXT* zgfx, wStream* stream, size_t
if (count > sizeof(zgfx->OutputBuffer) - zgfx->OutputCount)
return FALSE;
-
- if (count > zgfx->cBitsRemaining / 8)
+ else if (count > zgfx->cBitsRemaining / 8)
+ return FALSE;
+ else if (zgfx->pbInputCurrent + count > zgfx->pbInputEnd)
return FALSE;
CopyMemory(&(zgfx->OutputBuffer[zgfx->OutputCount]), zgfx->pbInputCurrent,
@@ -377,8 +383,8 @@ int zgfx_decompress(ZGFX_CONTEXT* zgfx, const BYTE* pSrcData, UINT32 SrcSize, BY
BYTE descriptor;
wStream* stream = Stream_New((BYTE*)pSrcData, SrcSize);
- if (!stream)
- return -1;
+ assert((zgfx) && "Assert failed: zgfx");
+ assert((stream) && "Assert failed: stream");
if (Stream_GetRemainingLength(stream) < 1)
goto fail;
@@ -32,6 +32,7 @@ SRC_URI = "git://github.com/FreeRDP/FreeRDP.git;branch=stable-2.0;protocol=https
file://CVE-2023-40569.patch \ file://CVE-2023-40569.patch \
file://CVE-2023-40589.patch \ file://CVE-2023-40589.patch \
file://CVE-2024-22211.patch \ file://CVE-2024-22211.patch \
file://CVE-2024-32039.patch \
" "
S = "${WORKDIR}/git" S = "${WORKDIR}/git"