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 <[email protected]>
---
 .../freerdp/freerdp/CVE-2024-32039.patch      | 78 +++++++++++++++++++
 .../recipes-support/freerdp/freerdp_2.6.1.bb  |  1 +
 2 files changed, 79 insertions(+)
 create mode 100644 meta-oe/recipes-support/freerdp/freerdp/CVE-2024-32039.patch

diff --git a/meta-oe/recipes-support/freerdp/freerdp/CVE-2024-32039.patch 
b/meta-oe/recipes-support/freerdp/freerdp/CVE-2024-32039.patch
new file mode 100644
index 0000000000..4def7320b9
--- /dev/null
+++ b/meta-oe/recipes-support/freerdp/freerdp/CVE-2024-32039.patch
@@ -0,0 +1,78 @@
+From 519c08d4720950dbeef8e671431ff8a6ea4e2927 Mon Sep 17 00:00:00 2001
+From: akallabeth <[email protected]>
+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 <[email protected]>
+---
+ 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;
diff --git a/meta-oe/recipes-support/freerdp/freerdp_2.6.1.bb 
b/meta-oe/recipes-support/freerdp/freerdp_2.6.1.bb
index 9ad95e1700..c616a55958 100644
--- a/meta-oe/recipes-support/freerdp/freerdp_2.6.1.bb
+++ b/meta-oe/recipes-support/freerdp/freerdp_2.6.1.bb
@@ -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-40589.patch \
            file://CVE-2024-22211.patch \
+           file://CVE-2024-32039.patch \
            "
 
 S = "${WORKDIR}/git"
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#123728): 
https://lists.openembedded.org/g/openembedded-devel/message/123728
Mute This Topic: https://lists.openembedded.org/mt/117395642/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to