import CS git freerdp-2.11.7-9.el8_10
This commit is contained in:
parent
36962efeba
commit
6802a27b97
36
SOURCES/allocations-fix-growth-of-preallocated-buffers.patch
Normal file
36
SOURCES/allocations-fix-growth-of-preallocated-buffers.patch
Normal file
@ -0,0 +1,36 @@
|
||||
From 563a19a683d6e0e7b1218e4558a0fb75333b5b34 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Tue, 28 Apr 2026 04:14:23 +0000
|
||||
Subject: [PATCH] [allocations] fix growth of preallocated buffers
|
||||
|
||||
Partial backport of commit 118afc0b954ba9d5632b7836ad24e454555ed113.
|
||||
|
||||
Only the `Stream_EnsureCapacity` fix is included. Other changes from
|
||||
the upstream commit (`sizeof(WCHAR)` replacements, collection growth
|
||||
patterns, environment block handling) are unrelated to CVE-2026-27951.
|
||||
|
||||
Made-with: Cursor
|
||||
---
|
||||
winpr/libwinpr/utils/stream.c | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/winpr/libwinpr/utils/stream.c b/winpr/libwinpr/utils/stream.c
|
||||
index cc119c7..cb145b0 100644
|
||||
--- a/winpr/libwinpr/utils/stream.c
|
||||
+++ b/winpr/libwinpr/utils/stream.c
|
||||
@@ -40,8 +40,10 @@ BOOL Stream_EnsureCapacity(wStream* s, size_t size)
|
||||
|
||||
do
|
||||
{
|
||||
- new_capacity *= 2;
|
||||
- } while (new_capacity < size);
|
||||
+ if (new_capacity > SIZE_MAX - 128ull)
|
||||
+ return FALSE;
|
||||
+ new_capacity += 128ull;
|
||||
+ } while (new_capacity <= size);
|
||||
|
||||
position = Stream_GetPosition(s);
|
||||
|
||||
--
|
||||
2.53.0
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
From 23320a6d5f2e1c8a9b7d6f4e3c2a1b0987654321 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Tue, 28 Apr 2026 04:25:58 +0000
|
||||
Subject: [PATCH] [cache,bitmap] initialize overallocated bitmap cache extra
|
||||
slot
|
||||
|
||||
Backport of commit 8270e0bb3d6726c947d57c93ba9caa92a052b557.
|
||||
|
||||
Adjusted hunk offsets for 2.11.7.
|
||||
|
||||
Made-with: Cursor
|
||||
---
|
||||
libfreerdp/cache/bitmap.c | 16 +++++++++++++++-
|
||||
1 file changed, 15 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libfreerdp/cache/bitmap.c b/libfreerdp/cache/bitmap.c
|
||||
index b8a4f21..23320a6 100644
|
||||
--- a/libfreerdp/cache/bitmap.c
|
||||
+++ b/libfreerdp/cache/bitmap.c
|
||||
@@ -303,6 +303,19 @@ rdpBitmapCache* bitmap_cache_new(rdpSettings* settings)
|
||||
cell->number = nr;
|
||||
}
|
||||
|
||||
+ /* initialize the overallocated extra slot for old RDP servers that send
|
||||
+ * cacheId == maxCells; use a minimal allocation since no protocol-negotiated
|
||||
+ * capacity exists for this slot */
|
||||
+ {
|
||||
+ BITMAP_V2_CELL* extra = &bitmapCache->cells[bitmapCache->maxCells];
|
||||
+ /* allocate an extra entry for BITMAP_CACHE_WAITING_LIST_INDEX */
|
||||
+ extra->entries = (rdpBitmap**)calloc(1, sizeof(rdpBitmap*));
|
||||
+
|
||||
+ if (!extra->entries)
|
||||
+ goto fail;
|
||||
+ extra->number = 0;
|
||||
+ }
|
||||
+
|
||||
return bitmapCache;
|
||||
fail:
|
||||
|
||||
@@ -315,7 +328,8 @@ void bitmap_cache_free(rdpBitmapCache* bitmapCache)
|
||||
if (bitmapCache)
|
||||
{
|
||||
UINT32 i;
|
||||
- for (i = 0; i < bitmapCache->maxCells; i++)
|
||||
+ /* iterate through maxCells + 1 to also free the overallocated extra slot */
|
||||
+ for (i = 0; i <= bitmapCache->maxCells; i++)
|
||||
{
|
||||
UINT32 j;
|
||||
BITMAP_V2_CELL* cell = &bitmapCache->cells[i];
|
||||
--
|
||||
2.53.0
|
||||
|
||||
33
SOURCES/cache-bitmap-overallocate-bitmap-cache.patch
Normal file
33
SOURCES/cache-bitmap-overallocate-bitmap-cache.patch
Normal file
@ -0,0 +1,33 @@
|
||||
From 608c5d40f6ab4cabd4d5793b2d641f401e146233 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Tue, 28 Apr 2026 04:25:52 +0000
|
||||
Subject: [PATCH] [cache,bitmap] overallocate bitmap cache
|
||||
|
||||
Backport of commit ffad58fd2b329efd81a3239e9d7e3c927b8e503f.
|
||||
|
||||
Adjusted hunk offsets for 2.11.7.
|
||||
|
||||
Made-with: Cursor
|
||||
---
|
||||
libfreerdp/cache/bitmap.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libfreerdp/cache/bitmap.c b/libfreerdp/cache/bitmap.c
|
||||
index 0ce2599..b8a4f21 100644
|
||||
--- a/libfreerdp/cache/bitmap.c
|
||||
+++ b/libfreerdp/cache/bitmap.c
|
||||
@@ -281,8 +281,10 @@ rdpBitmapCache* bitmap_cache_new(rdpSettings* settings)
|
||||
bitmapCache->settings = settings;
|
||||
bitmapCache->update = ((freerdp*)settings->instance)->update;
|
||||
bitmapCache->context = bitmapCache->update->context;
|
||||
+
|
||||
+ /* overallocate by 1. older RDP servers do send a off by 1 cache index. */
|
||||
bitmapCache->cells =
|
||||
- (BITMAP_V2_CELL*)calloc(settings->BitmapCacheV2NumCells, sizeof(BITMAP_V2_CELL));
|
||||
+ (BITMAP_V2_CELL*)calloc(settings->BitmapCacheV2NumCells + 1ull, sizeof(BITMAP_V2_CELL));
|
||||
|
||||
if (!bitmapCache->cells)
|
||||
goto fail;
|
||||
--
|
||||
2.53.0
|
||||
|
||||
170
SOURCES/client-x11-fix-deadlock-on-output-expose.patch
Normal file
170
SOURCES/client-x11-fix-deadlock-on-output-expose.patch
Normal file
@ -0,0 +1,170 @@
|
||||
From a25a6b8c53602d2023dd0ad685000dc006179e94 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Mon, 27 Apr 2026 20:12:42 +0000
|
||||
Subject: [PATCH] [client,x11] fix deadlock on output expose
|
||||
|
||||
Defer screen update from xf_event_Expose to after X11 lock is released,
|
||||
preventing a deadlock between X11 lock and railWindows lock.
|
||||
|
||||
Backport of commit a278ff74117444c635c50ffa5084ecf517171f5a.
|
||||
|
||||
Adjusted hunk offsets for 2.11.7.
|
||||
|
||||
Made-with: Cursor
|
||||
---
|
||||
client/X11/xf_client.c | 3 ++
|
||||
client/X11/xf_event.c | 77 ++++++++++++++++++++++++++++--------------
|
||||
client/X11/xf_event.h | 2 ++
|
||||
client/X11/xfreerdp.h | 4 +++
|
||||
4 files changed, 60 insertions(+), 26 deletions(-)
|
||||
|
||||
diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c
|
||||
index bd3eb0d..f14cb55 100644
|
||||
--- a/client/X11/xf_client.c
|
||||
+++ b/client/X11/xf_client.c
|
||||
@@ -516,6 +516,9 @@ static BOOL xf_process_x_events(freerdp* instance)
|
||||
xf_unlock_x11(xfc);
|
||||
if (!status)
|
||||
break;
|
||||
+ status = xf_event_update_screen(instance);
|
||||
+ if (!status)
|
||||
+ break;
|
||||
}
|
||||
|
||||
return status;
|
||||
diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c
|
||||
index e1421ad..524e5e3 100644
|
||||
--- a/client/X11/xf_event.c
|
||||
+++ b/client/X11/xf_event.c
|
||||
@@ -324,45 +324,34 @@ void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y)
|
||||
}
|
||||
static BOOL xf_event_Expose(xfContext* xfc, const XExposeEvent* event, BOOL app)
|
||||
{
|
||||
- int x, y;
|
||||
- int w, h;
|
||||
+ WINPR_ASSERT(xfc);
|
||||
+ WINPR_ASSERT(event);
|
||||
+
|
||||
rdpSettings* settings = xfc->context.settings;
|
||||
+ WINPR_ASSERT(settings);
|
||||
|
||||
if (!app && (settings->SmartSizing || settings->MultiTouchGestures))
|
||||
{
|
||||
- x = 0;
|
||||
- y = 0;
|
||||
- w = settings->DesktopWidth;
|
||||
- h = settings->DesktopHeight;
|
||||
+ xfc->exposedArea.x = 0;
|
||||
+ xfc->exposedArea.y = 0;
|
||||
+ xfc->exposedArea.w = settings->DesktopWidth;
|
||||
+ xfc->exposedArea.h = settings->DesktopHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
- x = event->x;
|
||||
- y = event->y;
|
||||
- w = event->width;
|
||||
- h = event->height;
|
||||
+ xfc->exposedArea.x = event->x;
|
||||
+ xfc->exposedArea.y = event->y;
|
||||
+ xfc->exposedArea.w = event->width;
|
||||
+ xfc->exposedArea.h = event->height;
|
||||
}
|
||||
|
||||
- if (!app)
|
||||
- {
|
||||
- if (xfc->context.gdi->gfx)
|
||||
- {
|
||||
- xf_OutputExpose(xfc, x, y, w, h);
|
||||
- return TRUE;
|
||||
- }
|
||||
- xf_draw_screen(xfc, x, y, w, h);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
|
||||
- if (appWindow)
|
||||
- xf_UpdateWindowArea(xfc, appWindow, x, y, w, h);
|
||||
- xf_rail_return_window(appWindow, FALSE);
|
||||
- }
|
||||
+ xfc->exposedWindow = event->window;
|
||||
+ xfc->exposeRequested = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+
|
||||
static BOOL xf_event_VisibilityNotify(xfContext* xfc, const XVisibilityEvent* event, BOOL app)
|
||||
{
|
||||
WINPR_UNUSED(app);
|
||||
@@ -1180,3 +1169,39 @@ BOOL xf_event_process(freerdp* instance, const XEvent* event)
|
||||
XSync(xfc->display, FALSE);
|
||||
return status;
|
||||
}
|
||||
+
|
||||
+BOOL xf_event_update_screen(freerdp* instance)
|
||||
+{
|
||||
+ WINPR_ASSERT(instance);
|
||||
+
|
||||
+ xfContext* xfc = (xfContext*)instance->context;
|
||||
+ WINPR_ASSERT(xfc);
|
||||
+
|
||||
+ rdpSettings* settings = xfc->context.settings;
|
||||
+ WINPR_ASSERT(settings);
|
||||
+
|
||||
+ if (!xfc->exposeRequested)
|
||||
+ return TRUE;
|
||||
+ xfc->exposeRequested = FALSE;
|
||||
+
|
||||
+ if (!xfc->remote_app)
|
||||
+ {
|
||||
+ if (xfc->context.gdi->gfx)
|
||||
+ {
|
||||
+ xf_OutputExpose(xfc, xfc->exposedArea.x, xfc->exposedArea.y,
|
||||
+ xfc->exposedArea.w, xfc->exposedArea.h);
|
||||
+ return TRUE;
|
||||
+ }
|
||||
+ xf_draw_screen(xfc, xfc->exposedArea.x, xfc->exposedArea.y, xfc->exposedArea.w,
|
||||
+ xfc->exposedArea.h);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, xfc->exposedWindow);
|
||||
+ if (appWindow)
|
||||
+ xf_UpdateWindowArea(xfc, appWindow, xfc->exposedArea.x, xfc->exposedArea.y,
|
||||
+ xfc->exposedArea.w, xfc->exposedArea.h);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
+ }
|
||||
+ return TRUE;
|
||||
+}
|
||||
diff --git a/client/X11/xf_event.h b/client/X11/xf_event.h
|
||||
index 2269d3e..e025d19 100644
|
||||
--- a/client/X11/xf_event.h
|
||||
+++ b/client/X11/xf_event.h
|
||||
@@ -29,6 +29,8 @@ BOOL xf_event_action_script_init(xfContext* xfc);
|
||||
void xf_event_action_script_free(xfContext* xfc);
|
||||
|
||||
BOOL xf_event_process(freerdp* instance, const XEvent* event);
|
||||
+
|
||||
+BOOL xf_event_update_screen(freerdp* instance);
|
||||
void xf_event_SendClientEvent(xfContext* xfc, xfWindow* window, Atom atom, unsigned int numArgs,
|
||||
...);
|
||||
|
||||
diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h
|
||||
index 636e60a..a1a33b2 100644
|
||||
--- a/client/X11/xfreerdp.h
|
||||
+++ b/client/X11/xfreerdp.h
|
||||
@@ -261,6 +261,10 @@ struct xf_context
|
||||
wHashTable* railWindows;
|
||||
xfRailIconCache* railIconCache;
|
||||
|
||||
+ BOOL exposeRequested;
|
||||
+ GDI_RGN exposedArea;
|
||||
+ Window exposedWindow;
|
||||
+
|
||||
BOOL xkbAvailable;
|
||||
BOOL xrenderAvailable;
|
||||
|
||||
--
|
||||
2.53.0
|
||||
|
||||
45
SOURCES/client-x11-fix-xf_rail_window_common-cleanup.patch
Normal file
45
SOURCES/client-x11-fix-xf_rail_window_common-cleanup.patch
Normal file
@ -0,0 +1,45 @@
|
||||
From 562cc4b33257074d1d50535138998bc81796d447 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Mon, 27 Apr 2026 19:00:00 +0000
|
||||
Subject: [PATCH] [client,x11] fix xf_rail_window_common cleanup
|
||||
|
||||
Backport of commit b4f0f0a18fe53aa8d47d062f91471f4e9c5e0d51.
|
||||
|
||||
Adjusted hunk offsets for 2.11.7.
|
||||
|
||||
Made-with: Cursor
|
||||
---
|
||||
client/X11/xf_rail.c | 6 +-----
|
||||
1 file changed, 1 insertion(+), 5 deletions(-)
|
||||
|
||||
diff --git a/client/X11/xf_rail.c b/client/X11/xf_rail.c
|
||||
index 242c54b..4c4f47d 100644
|
||||
--- a/client/X11/xf_rail.c
|
||||
+++ b/client/X11/xf_rail.c
|
||||
@@ -260,11 +260,10 @@ static void window_state_log_style(wLog* log, const WINDOW_STATE_ORDER* windowSt
|
||||
static BOOL xf_rail_window_common(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
|
||||
const WINDOW_STATE_ORDER* windowState)
|
||||
{
|
||||
- xfAppWindow* appWindow = NULL;
|
||||
xfContext* xfc = (xfContext*)context;
|
||||
UINT32 fieldFlags = orderInfo->fieldFlags;
|
||||
BOOL position_or_size_updated = FALSE;
|
||||
- appWindow = xf_rail_get_window(xfc, orderInfo->windowId);
|
||||
+ xfAppWindow* appWindow = xf_rail_get_window(xfc, orderInfo->windowId);
|
||||
|
||||
if (fieldFlags & WINDOW_ORDER_STATE_NEW)
|
||||
{
|
||||
@@ -310,10 +309,7 @@ static BOOL xf_rail_window_common(rdpContext* context, const WINDOW_ORDER_INFO*
|
||||
}
|
||||
|
||||
if (!appWindow->title)
|
||||
- {
|
||||
- free(appWindow);
|
||||
return FALSE;
|
||||
- }
|
||||
|
||||
xf_AppWindowInit(xfc, appWindow);
|
||||
}
|
||||
--
|
||||
2.53.0
|
||||
|
||||
331
SOURCES/client-x11-improve-rails-window-locking.patch
Normal file
331
SOURCES/client-x11-improve-rails-window-locking.patch
Normal file
@ -0,0 +1,331 @@
|
||||
From e6edabe690ad8de63af327403e8371b6ef1319e2 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Mon, 27 Apr 2026 19:38:47 +0000
|
||||
Subject: [PATCH] [client,x11] improve rails window locking
|
||||
|
||||
Backport of commit 78fd7f580d5f9e6d9d582d82e5ea96003844fbdf.
|
||||
|
||||
Adapted for 2.11.7: C89 declaration style, simplified
|
||||
`xfAppWindowsLockFrom`/`UnlockFrom` signatures (no
|
||||
`WINPR_ATTR_UNUSED`), `XSetTransientForHint` inline error handling.
|
||||
|
||||
Made-with: Cursor
|
||||
---
|
||||
client/X11/xf_event.c | 7 ++----
|
||||
client/X11/xf_graphics.c | 4 +--
|
||||
client/X11/xf_rail.c | 53 +++++++++++++++++++--------------------
|
||||
client/X11/xf_rail.h | 10 ++++++--
|
||||
client/X11/xf_window.c | 54 ++++++++++++++++++++++++++++++++--------
|
||||
client/X11/xf_window.h | 11 ++++++--
|
||||
6 files changed, 89 insertions(+), 50 deletions(-)
|
||||
|
||||
diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c
|
||||
index 8bebcd4..8801fbd 100644
|
||||
--- a/client/X11/xf_event.c
|
||||
+++ b/client/X11/xf_event.c
|
||||
@@ -354,13 +354,10 @@ static BOOL xf_event_Expose(xfContext* xfc, const XExposeEvent* event, BOOL app)
|
||||
}
|
||||
else
|
||||
{
|
||||
- xfAppWindow* appWindow;
|
||||
- appWindow = xf_AppWindowFromX11Window(xfc, event->window);
|
||||
-
|
||||
+ xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
|
||||
if (appWindow)
|
||||
- {
|
||||
xf_UpdateWindowArea(xfc, appWindow, x, y, w, h);
|
||||
- }
|
||||
+ xf_rail_return_window(appWindow);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c
|
||||
index 70979bd..f5b4f3d 100644
|
||||
--- a/client/X11/xf_graphics.c
|
||||
+++ b/client/X11/xf_graphics.c
|
||||
@@ -372,12 +372,12 @@ static Window xf_Pointer_get_window(xfContext* xfc)
|
||||
if (xfc->remote_app)
|
||||
{
|
||||
Window w = 0;
|
||||
- EnterCriticalSection(&xfc->railWindows->lock);
|
||||
+ xf_AppWindowsLock(xfc);
|
||||
if (!xfc->appWindow)
|
||||
WLog_WARN(TAG, "xf_Pointer: Invalid appWindow");
|
||||
else
|
||||
w = xfc->appWindow->handle;
|
||||
- LeaveCriticalSection(&xfc->railWindows->lock);
|
||||
+ xf_AppWindowsUnlock(xfc);
|
||||
return w;
|
||||
}
|
||||
else
|
||||
diff --git a/client/X11/xf_rail.c b/client/X11/xf_rail.c
|
||||
index 1938bdd..1e57046 100644
|
||||
--- a/client/X11/xf_rail.c
|
||||
+++ b/client/X11/xf_rail.c
|
||||
@@ -101,9 +101,10 @@ void xf_rail_send_activate(xfContext* xfc, Window xwindow, BOOL enabled)
|
||||
xf_SetWindowStyle(xfc, appWindow, 0, 0);
|
||||
|
||||
activate.windowId = appWindow->windowId;
|
||||
+ xf_rail_return_window(appWindow);
|
||||
+
|
||||
activate.enabled = enabled;
|
||||
xfc->rail->ClientActivate(xfc->rail, &activate);
|
||||
- xf_rail_return_window(appWindow);
|
||||
}
|
||||
|
||||
void xf_rail_send_client_system_command(xfContext* xfc, UINT32 windowId, UINT16 command)
|
||||
@@ -260,6 +261,7 @@ void xf_rail_paint(xfContext* xfc, INT32 uleft, INT32 utop, UINT32 uright, UINT3
|
||||
static BOOL xf_rail_window_common(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
|
||||
const WINDOW_STATE_ORDER* windowState)
|
||||
{
|
||||
+ BOOL rc = FALSE;
|
||||
xfContext* xfc = (xfContext*)context;
|
||||
UINT32 fieldFlags = orderInfo->fieldFlags;
|
||||
BOOL position_or_size_updated = FALSE;
|
||||
@@ -379,14 +381,14 @@ static BOOL xf_rail_window_common(rdpContext* context, const WINDOW_ORDER_INFO*
|
||||
if (!(title = _strdup("")))
|
||||
{
|
||||
WLog_ERR(TAG, "failed to duplicate empty window title string");
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
}
|
||||
}
|
||||
else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)windowState->titleInfo.string,
|
||||
windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1)
|
||||
{
|
||||
WLog_ERR(TAG, "failed to convert window title");
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
free(appWindow->title);
|
||||
@@ -427,7 +429,7 @@ static BOOL xf_rail_window_common(rdpContext* context, const WINDOW_ORDER_INFO*
|
||||
(RECTANGLE_16*)calloc(appWindow->numWindowRects, sizeof(RECTANGLE_16));
|
||||
|
||||
if (!appWindow->windowRects)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
CopyMemory(appWindow->windowRects, windowState->windowRects,
|
||||
appWindow->numWindowRects * sizeof(RECTANGLE_16));
|
||||
@@ -456,7 +458,7 @@ static BOOL xf_rail_window_common(rdpContext* context, const WINDOW_ORDER_INFO*
|
||||
(RECTANGLE_16*)calloc(appWindow->numVisibilityRects, sizeof(RECTANGLE_16));
|
||||
|
||||
if (!appWindow->visibilityRects)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
CopyMemory(appWindow->visibilityRects, windowState->visibilityRects,
|
||||
appWindow->numVisibilityRects * sizeof(RECTANGLE_16));
|
||||
@@ -522,7 +524,10 @@ static BOOL xf_rail_window_common(rdpContext* context, const WINDOW_ORDER_INFO*
|
||||
{
|
||||
xf_SetWindowRects(xfc, appWindow, appWindow->windowRects, appWindow->numWindowRects);
|
||||
}*/
|
||||
- return TRUE;
|
||||
+ rc = TRUE;
|
||||
+fail:
|
||||
+ xf_rail_return_window(appWindow);
|
||||
+ return rc;
|
||||
}
|
||||
|
||||
static BOOL xf_rail_window_delete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo)
|
||||
@@ -1000,14 +1005,14 @@ static UINT xf_rail_server_local_move_size(RailClientContext* context,
|
||||
x = localMoveSize->posX;
|
||||
y = localMoveSize->posY;
|
||||
/* FIXME: local keyboard moves not working */
|
||||
- return CHANNEL_RC_OK;
|
||||
+ break;
|
||||
|
||||
case RAIL_WMSZ_KEYSIZE:
|
||||
direction = _NET_WM_MOVERESIZE_SIZE_KEYBOARD;
|
||||
x = localMoveSize->posX;
|
||||
y = localMoveSize->posY;
|
||||
/* FIXME: local keyboard moves not working */
|
||||
- return CHANNEL_RC_OK;
|
||||
+ break;
|
||||
}
|
||||
|
||||
if (localMoveSize->isMoveSizeStart)
|
||||
@@ -1173,9 +1178,17 @@ xfAppWindow* xf_rail_add_window(xfContext* xfc, UINT64 id, UINT32 x, UINT32 y, U
|
||||
appWindow->y = y;
|
||||
appWindow->width = width;
|
||||
appWindow->height = height;
|
||||
- xf_AppWindowCreate(xfc, appWindow);
|
||||
- HashTable_Add(xfc->railWindows, &appWindow->windowId, (void*)appWindow);
|
||||
+ xf_AppWindowsLock(xfc);
|
||||
+ if (xf_AppWindowCreate(xfc, appWindow) < 0)
|
||||
+ goto fail;
|
||||
+
|
||||
+ if (HashTable_Add(xfc->railWindows, &appWindow->windowId, (void*)appWindow) < 0)
|
||||
+ goto fail;
|
||||
return appWindow;
|
||||
+fail:
|
||||
+ free(appWindow);
|
||||
+ xf_AppWindowsUnlock(xfc);
|
||||
+ return NULL;
|
||||
}
|
||||
|
||||
BOOL xf_rail_del_window(xfContext* xfc, UINT64 id)
|
||||
@@ -1189,26 +1202,10 @@ BOOL xf_rail_del_window(xfContext* xfc, UINT64 id)
|
||||
return HashTable_Remove(xfc->railWindows, &id);
|
||||
}
|
||||
|
||||
-xfAppWindow* xf_rail_get_window(xfContext* xfc, UINT64 id)
|
||||
-{
|
||||
- if (!xfc)
|
||||
- return NULL;
|
||||
-
|
||||
- if (!xfc->railWindows)
|
||||
- return NULL;
|
||||
-
|
||||
- EnterCriticalSection(&xfc->railWindows->lock);
|
||||
- xfAppWindow* window = HashTable_GetItemValue(xfc->railWindows, &id);
|
||||
- if (!window)
|
||||
- LeaveCriticalSection(&xfc->railWindows->lock);
|
||||
-
|
||||
- return window;
|
||||
-}
|
||||
-
|
||||
-void xf_rail_return_window(xfAppWindow* window)
|
||||
+void xf_rail_return_windowFrom(xfAppWindow* window, const char* file, const char* fkt, size_t line)
|
||||
{
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
- LeaveCriticalSection(&window->xfc->railWindows->lock);
|
||||
+ xfAppWindowsUnlockFrom(window->xfc, file, fkt, line);
|
||||
}
|
||||
diff --git a/client/X11/xf_rail.h b/client/X11/xf_rail.h
|
||||
index 5fbc316..83d5fff 100644
|
||||
--- a/client/X11/xf_rail.h
|
||||
+++ b/client/X11/xf_rail.h
|
||||
@@ -36,9 +36,15 @@ void xf_rail_disable_remoteapp_mode(xfContext* xfc);
|
||||
xfAppWindow* xf_rail_add_window(xfContext* xfc, UINT64 id, UINT32 x, UINT32 y, UINT32 width,
|
||||
UINT32 height, UINT32 surfaceId);
|
||||
|
||||
-void xf_rail_return_window(xfAppWindow* window);
|
||||
+#define xf_rail_return_window(window) \
|
||||
+ xf_rail_return_windowFrom((window), __FILE__, __func__, __LINE__)
|
||||
+void xf_rail_return_windowFrom(xfAppWindow* window, const char* file, const char* fkt, size_t line);
|
||||
|
||||
-xfAppWindow* xf_rail_get_window(xfContext* xfc, UINT64 id);
|
||||
+#define xf_rail_get_window(xfc, id) \
|
||||
+ xf_rail_get_windowFrom((xfc), (id), __FILE__, __func__, __LINE__)
|
||||
+
|
||||
+xfAppWindow* xf_rail_get_windowFrom(xfContext* xfc, UINT64 id, const char* file, const char* fkt,
|
||||
+ size_t line);
|
||||
|
||||
BOOL xf_rail_del_window(xfContext* xfc, UINT64 id);
|
||||
|
||||
diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c
|
||||
index 7e936fe..09b4a81 100644
|
||||
--- a/client/X11/xf_window.c
|
||||
+++ b/client/X11/xf_window.c
|
||||
@@ -1116,39 +1116,71 @@ void xf_DestroyWindow(xfContext* xfc, xfAppWindow* appWindow)
|
||||
free(appWindow);
|
||||
}
|
||||
|
||||
-xfAppWindow* xf_AppWindowFromX11Window(xfContext* xfc, Window wnd)
|
||||
+static xfAppWindow* get_windowUnlocked(xfContext* xfc, UINT64 id)
|
||||
+{
|
||||
+ WINPR_ASSERT(xfc);
|
||||
+ return HashTable_GetItemValue(xfc->railWindows, &id);
|
||||
+}
|
||||
+
|
||||
+xfAppWindow* xf_rail_get_windowFrom(xfContext* xfc, UINT64 id, const char* file, const char* fkt,
|
||||
+ size_t line)
|
||||
+{
|
||||
+ if (!xfc)
|
||||
+ return NULL;
|
||||
+
|
||||
+ if (!xfc->railWindows)
|
||||
+ return NULL;
|
||||
+
|
||||
+ xfAppWindowsLockFrom(xfc, file, fkt, line);
|
||||
+ xfAppWindow* window = get_windowUnlocked(xfc, id);
|
||||
+ if (!window)
|
||||
+ xfAppWindowsUnlockFrom(xfc, file, fkt, line);
|
||||
+
|
||||
+ return window;
|
||||
+}
|
||||
+
|
||||
+xfAppWindow* xf_AppWindowFromX11WindowFrom(xfContext* xfc, Window wnd, const char* file,
|
||||
+ const char* fkt, size_t line)
|
||||
{
|
||||
- int index;
|
||||
- int count;
|
||||
ULONG_PTR* pKeys = NULL;
|
||||
- xfAppWindow* appWindow;
|
||||
|
||||
if (!xfc->railWindows)
|
||||
return NULL;
|
||||
|
||||
- EnterCriticalSection(&xfc->railWindows->lock);
|
||||
- count = HashTable_GetKeys(xfc->railWindows, &pKeys);
|
||||
+ xfAppWindowsLockFrom(xfc, file, fkt, line);
|
||||
+ size_t count = HashTable_GetKeys(xfc->railWindows, &pKeys);
|
||||
|
||||
- for (index = 0; index < count; index++)
|
||||
+ for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
- appWindow = HashTable_GetItemValue(xfc->railWindows, (void*)pKeys[index]);
|
||||
+ xfAppWindow* appWindow = get_windowUnlocked(xfc, *(UINT64*)pKeys[index]);
|
||||
|
||||
if (!appWindow)
|
||||
{
|
||||
- LeaveCriticalSection(&xfc->railWindows->lock);
|
||||
+ xfAppWindowsUnlockFrom(xfc, file, fkt, line);
|
||||
free(pKeys);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (appWindow->handle == wnd)
|
||||
{
|
||||
- LeaveCriticalSection(&xfc->railWindows->lock);
|
||||
free(pKeys);
|
||||
return appWindow;
|
||||
}
|
||||
}
|
||||
|
||||
- LeaveCriticalSection(&xfc->railWindows->lock);
|
||||
+ xfAppWindowsUnlockFrom(xfc, file, fkt, line);
|
||||
free(pKeys);
|
||||
return NULL;
|
||||
}
|
||||
+
|
||||
+void xfAppWindowsLockFrom(xfContext* xfc, const char* file, const char* fkt, size_t line)
|
||||
+{
|
||||
+ WINPR_ASSERT(xfc);
|
||||
+ EnterCriticalSection(&xfc->railWindows->lock);
|
||||
+}
|
||||
+
|
||||
+void xfAppWindowsUnlockFrom(xfContext* xfc, const char* file, const char* fkt, size_t line)
|
||||
+{
|
||||
+ WINPR_ASSERT(xfc);
|
||||
+ LeaveCriticalSection(&xfc->railWindows->lock);
|
||||
+}
|
||||
diff --git a/client/X11/xf_window.h b/client/X11/xf_window.h
|
||||
index c7702ed..45d40bb 100644
|
||||
--- a/client/X11/xf_window.h
|
||||
+++ b/client/X11/xf_window.h
|
||||
@@ -187,8 +187,15 @@ void xf_SetWindowMinMaxInfo(xfContext* xfc, xfAppWindow* appWindow, int maxWidth
|
||||
int maxTrackWidth, int maxTrackHeight);
|
||||
void xf_StartLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow, int direction, int x, int y);
|
||||
void xf_EndLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow);
|
||||
-void xf_rail_return_window(xfAppWindow* window);
|
||||
+#define xf_AppWindowFromX11Window(xfc, wnd) \
|
||||
+ xf_AppWindowFromX11WindowFrom((xfc), (wnd), __FILE__, __func__, __LINE__)
|
||||
+xfAppWindow* xf_AppWindowFromX11WindowFrom(xfContext* xfc, Window wnd, const char* file,
|
||||
+ const char* fkt, size_t line);
|
||||
|
||||
-xfAppWindow* xf_AppWindowFromX11Window(xfContext* xfc, Window wnd);
|
||||
+#define xf_AppWindowsLock(xfc) xfAppWindowsLockFrom((xfc), __FILE__, __func__, __LINE__)
|
||||
+void xfAppWindowsLockFrom(xfContext* xfc, const char* file, const char* fkt, size_t line);
|
||||
+
|
||||
+#define xf_AppWindowsUnlock(xfc) xfAppWindowsUnlockFrom((xfc), __FILE__, __func__, __LINE__)
|
||||
+void xfAppWindowsUnlockFrom(xfContext* xfc, const char* file, const char* fkt, size_t line);
|
||||
|
||||
#endif /* FREERDP_CLIENT_X11_WINDOW_H */
|
||||
--
|
||||
2.53.0
|
||||
|
||||
404
SOURCES/client-x11-lock-appwindow.patch
Normal file
404
SOURCES/client-x11-lock-appwindow.patch
Normal file
@ -0,0 +1,404 @@
|
||||
From 8152c347e96c1e3af15cb2551d4efb6740fe9f87 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Mon, 27 Apr 2026 19:37:40 +0000
|
||||
Subject: [PATCH] [client,x11] lock appWindow
|
||||
|
||||
Backport of commit 1994e9844212a6dfe0ff12309fef520e888986b5.
|
||||
|
||||
Adapted for 2.11.7: C89 declaration style, `(Atom)` cast for
|
||||
`xfc->_NET_WM_STATE` comparison, `xf_rail_send_client_system_command`
|
||||
return value handling adapted (no direct return), `HashTable_GetKeys`
|
||||
variable pre-declared, `xf_AppWindowFromX11Window` loop adapted.
|
||||
|
||||
Made-with: Cursor
|
||||
---
|
||||
client/X11/xf_event.c | 46 ++++++++++++++++-----------
|
||||
client/X11/xf_graphics.c | 10 +++---
|
||||
client/X11/xf_rail.c | 68 +++++++++++++++++++++++++---------------
|
||||
client/X11/xf_rail.h | 3 ++
|
||||
client/X11/xf_window.c | 13 +++++++-
|
||||
client/X11/xf_window.h | 2 ++
|
||||
6 files changed, 94 insertions(+), 48 deletions(-)
|
||||
|
||||
diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c
|
||||
index eb50ef1..8bebcd4 100644
|
||||
--- a/client/X11/xf_event.c
|
||||
+++ b/client/X11/xf_event.c
|
||||
@@ -388,7 +388,9 @@ BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window win
|
||||
if (app)
|
||||
{
|
||||
/* make sure window exists */
|
||||
- if (!xf_AppWindowFromX11Window(xfc, window))
|
||||
+ xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, window);
|
||||
+ xf_rail_return_window(appWindow);
|
||||
+ if (!appWindow)
|
||||
return TRUE;
|
||||
|
||||
/* Translate to desktop coordinates */
|
||||
@@ -465,7 +467,9 @@ BOOL xf_generic_ButtonEvent(xfContext* xfc, int x, int y, int button, Window win
|
||||
if (app)
|
||||
{
|
||||
/* make sure window exists */
|
||||
- if (!xf_AppWindowFromX11Window(xfc, window))
|
||||
+ xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, window);
|
||||
+ xf_rail_return_window(appWindow);
|
||||
+ if (!appWindow)
|
||||
return TRUE;
|
||||
|
||||
/* Translate to desktop coordinates */
|
||||
@@ -574,9 +578,8 @@ static BOOL xf_event_FocusIn(xfContext* xfc, const XFocusInEvent* event, BOOL ap
|
||||
/* Update the server with any window changes that occurred while the window was not focused.
|
||||
*/
|
||||
if (appWindow)
|
||||
- {
|
||||
xf_rail_adjust_position(xfc, appWindow);
|
||||
- }
|
||||
+ xf_rail_return_window(appWindow);
|
||||
}
|
||||
|
||||
xf_keyboard_focus_in(xfc);
|
||||
@@ -623,15 +626,13 @@ static BOOL xf_event_ClientMessage(xfContext* xfc, const XClientMessageEvent* ev
|
||||
{
|
||||
if (app)
|
||||
{
|
||||
- xfAppWindow* appWindow;
|
||||
- appWindow = xf_AppWindowFromX11Window(xfc, event->window);
|
||||
+ BOOL rc = TRUE;
|
||||
+ xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
|
||||
|
||||
if (appWindow)
|
||||
- {
|
||||
xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_CLOSE);
|
||||
- }
|
||||
-
|
||||
- return TRUE;
|
||||
+ xf_rail_return_window(appWindow);
|
||||
+ return rc;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -665,6 +666,7 @@ static BOOL xf_event_EnterNotify(xfContext* xfc, const XEnterWindowEvent* event,
|
||||
|
||||
/* keep track of which window has focus so that we can apply pointer updates */
|
||||
xfc->appWindow = appWindow;
|
||||
+ xf_rail_return_window(appWindow);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -684,6 +686,7 @@ static BOOL xf_event_LeaveNotify(xfContext* xfc, const XLeaveWindowEvent* event,
|
||||
/* keep track of which window has focus so that we can apply pointer updates */
|
||||
if (xfc->appWindow == appWindow)
|
||||
xfc->appWindow = NULL;
|
||||
+ xf_rail_return_window(appWindow);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -774,6 +777,7 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, const XConfigureEvent* even
|
||||
xf_rail_adjust_position(xfc, appWindow);
|
||||
}
|
||||
}
|
||||
+ xf_rail_return_window(appWindow);
|
||||
}
|
||||
return xf_pointer_update_scale(xfc);
|
||||
}
|
||||
@@ -798,6 +802,7 @@ static BOOL xf_event_MapNotify(xfContext* xfc, const XMapEvent* event, BOOL app)
|
||||
// xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_RESTORE);
|
||||
appWindow->is_mapped = TRUE;
|
||||
}
|
||||
+ xf_rail_return_window(appWindow);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -813,15 +818,14 @@ static BOOL xf_event_UnmapNotify(xfContext* xfc, const XUnmapEvent* event, BOOL
|
||||
xf_keyboard_release_all_keypress(xfc);
|
||||
|
||||
if (!app)
|
||||
- gdi_send_suppress_output(xfc->context.gdi, TRUE);
|
||||
- else
|
||||
+ return gdi_send_suppress_output(xfc->context.gdi, TRUE);
|
||||
+
|
||||
{
|
||||
appWindow = xf_AppWindowFromX11Window(xfc, event->window);
|
||||
|
||||
if (appWindow)
|
||||
- {
|
||||
appWindow->is_mapped = FALSE;
|
||||
- }
|
||||
+ xf_rail_return_window(appWindow);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -829,6 +833,7 @@ static BOOL xf_event_UnmapNotify(xfContext* xfc, const XUnmapEvent* event, BOOL
|
||||
|
||||
static BOOL xf_event_PropertyNotify(xfContext* xfc, const XPropertyEvent* event, BOOL app)
|
||||
{
|
||||
+ BOOL rc = TRUE;
|
||||
WINPR_ASSERT(xfc);
|
||||
WINPR_ASSERT(event);
|
||||
|
||||
@@ -856,7 +861,7 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, const XPropertyEvent* event,
|
||||
appWindow = xf_AppWindowFromX11Window(xfc, event->window);
|
||||
|
||||
if (!appWindow)
|
||||
- return TRUE;
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
if ((Atom)event->atom == xfc->_NET_WM_STATE)
|
||||
@@ -949,10 +954,13 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, const XPropertyEvent* event,
|
||||
}
|
||||
}
|
||||
else if (minimizedChanged)
|
||||
- gdi_send_suppress_output(xfc->context.gdi, minimized);
|
||||
+ rc = gdi_send_suppress_output(xfc->context.gdi, minimized);
|
||||
+
|
||||
+ fail:
|
||||
+ xf_rail_return_window(appWindow);
|
||||
}
|
||||
|
||||
- return TRUE;
|
||||
+ return rc;
|
||||
}
|
||||
|
||||
static BOOL xf_event_suppress_events(xfContext* xfc, xfAppWindow* appWindow, const XEvent* event)
|
||||
@@ -1060,7 +1068,9 @@ BOOL xf_event_process(freerdp* instance, const XEvent* event)
|
||||
/* Update "current" window for cursor change orders */
|
||||
xfc->appWindow = appWindow;
|
||||
|
||||
- if (xf_event_suppress_events(xfc, appWindow, event))
|
||||
+ BOOL suppress = xf_event_suppress_events(xfc, appWindow, event);
|
||||
+ xf_rail_return_window(appWindow);
|
||||
+ if (suppress)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c
|
||||
index d596b23..70979bd 100644
|
||||
--- a/client/X11/xf_graphics.c
|
||||
+++ b/client/X11/xf_graphics.c
|
||||
@@ -371,12 +371,14 @@ static Window xf_Pointer_get_window(xfContext* xfc)
|
||||
}
|
||||
if (xfc->remote_app)
|
||||
{
|
||||
+ Window w = 0;
|
||||
+ EnterCriticalSection(&xfc->railWindows->lock);
|
||||
if (!xfc->appWindow)
|
||||
- {
|
||||
WLog_WARN(TAG, "xf_Pointer: Invalid appWindow");
|
||||
- return 0;
|
||||
- }
|
||||
- return xfc->appWindow->handle;
|
||||
+ else
|
||||
+ w = xfc->appWindow->handle;
|
||||
+ LeaveCriticalSection(&xfc->railWindows->lock);
|
||||
+ return w;
|
||||
}
|
||||
else
|
||||
{
|
||||
diff --git a/client/X11/xf_rail.c b/client/X11/xf_rail.c
|
||||
index fdc2244..1938bdd 100644
|
||||
--- a/client/X11/xf_rail.c
|
||||
+++ b/client/X11/xf_rail.c
|
||||
@@ -103,6 +103,7 @@ void xf_rail_send_activate(xfContext* xfc, Window xwindow, BOOL enabled)
|
||||
activate.windowId = appWindow->windowId;
|
||||
activate.enabled = enabled;
|
||||
xfc->rail->ClientActivate(xfc->rail, &activate);
|
||||
+ xf_rail_return_window(appWindow);
|
||||
}
|
||||
|
||||
void xf_rail_send_client_system_command(xfContext* xfc, UINT32 windowId, UINT16 command)
|
||||
@@ -658,61 +659,63 @@ static void xf_rail_set_window_icon(xfContext* xfc, xfAppWindow* railWindow, xfR
|
||||
static BOOL xf_rail_window_icon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
|
||||
const WINDOW_ICON_ORDER* windowIcon)
|
||||
{
|
||||
+ BOOL rc = FALSE;
|
||||
xfContext* xfc = (xfContext*)context;
|
||||
- xfAppWindow* railWindow;
|
||||
- xfRailIcon* icon;
|
||||
- BOOL replaceIcon;
|
||||
- railWindow = xf_rail_get_window(xfc, orderInfo->windowId);
|
||||
+ BOOL replaceIcon = 0;
|
||||
+ xfAppWindow* railWindow = xf_rail_get_window(xfc, orderInfo->windowId);
|
||||
|
||||
if (!railWindow)
|
||||
return TRUE;
|
||||
|
||||
- icon = RailIconCache_Lookup(xfc->railIconCache, windowIcon->iconInfo->cacheId,
|
||||
+ xfRailIcon* icon = RailIconCache_Lookup(xfc->railIconCache, windowIcon->iconInfo->cacheId,
|
||||
windowIcon->iconInfo->cacheEntry);
|
||||
|
||||
if (!icon)
|
||||
{
|
||||
WLog_WARN(TAG, "failed to get icon from cache %02X:%04X", windowIcon->iconInfo->cacheId,
|
||||
windowIcon->iconInfo->cacheEntry);
|
||||
- return FALSE;
|
||||
}
|
||||
-
|
||||
- if (!convert_rail_icon(windowIcon->iconInfo, icon))
|
||||
+ else if (!convert_rail_icon(windowIcon->iconInfo, icon))
|
||||
{
|
||||
WLog_WARN(TAG, "failed to convert icon for window %08X", orderInfo->windowId);
|
||||
- return FALSE;
|
||||
}
|
||||
-
|
||||
- replaceIcon = !!(orderInfo->fieldFlags & WINDOW_ORDER_STATE_NEW);
|
||||
- xf_rail_set_window_icon(xfc, railWindow, icon, replaceIcon);
|
||||
- return TRUE;
|
||||
+ else
|
||||
+ {
|
||||
+ replaceIcon = !!(orderInfo->fieldFlags & WINDOW_ORDER_STATE_NEW);
|
||||
+ xf_rail_set_window_icon(xfc, railWindow, icon, replaceIcon);
|
||||
+ rc = TRUE;
|
||||
+ }
|
||||
+ xf_rail_return_window(railWindow);
|
||||
+ return rc;
|
||||
}
|
||||
|
||||
static BOOL xf_rail_window_cached_icon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
|
||||
const WINDOW_CACHED_ICON_ORDER* windowCachedIcon)
|
||||
{
|
||||
+ BOOL rc = FALSE;
|
||||
xfContext* xfc = (xfContext*)context;
|
||||
- xfAppWindow* railWindow;
|
||||
- xfRailIcon* icon;
|
||||
- BOOL replaceIcon;
|
||||
- railWindow = xf_rail_get_window(xfc, orderInfo->windowId);
|
||||
+ BOOL replaceIcon = 0;
|
||||
+ xfAppWindow* railWindow = xf_rail_get_window(xfc, orderInfo->windowId);
|
||||
|
||||
if (!railWindow)
|
||||
return TRUE;
|
||||
|
||||
- icon = RailIconCache_Lookup(xfc->railIconCache, windowCachedIcon->cachedIcon.cacheId,
|
||||
+ xfRailIcon* icon = RailIconCache_Lookup(xfc->railIconCache, windowCachedIcon->cachedIcon.cacheId,
|
||||
windowCachedIcon->cachedIcon.cacheEntry);
|
||||
|
||||
if (!icon)
|
||||
{
|
||||
WLog_WARN(TAG, "failed to get icon from cache %02X:%04X",
|
||||
windowCachedIcon->cachedIcon.cacheId, windowCachedIcon->cachedIcon.cacheEntry);
|
||||
- return FALSE;
|
||||
}
|
||||
-
|
||||
- replaceIcon = !!(orderInfo->fieldFlags & WINDOW_ORDER_STATE_NEW);
|
||||
- xf_rail_set_window_icon(xfc, railWindow, icon, replaceIcon);
|
||||
- return TRUE;
|
||||
+ else
|
||||
+ {
|
||||
+ replaceIcon = !!(orderInfo->fieldFlags & WINDOW_ORDER_STATE_NEW);
|
||||
+ xf_rail_set_window_icon(xfc, railWindow, icon, replaceIcon);
|
||||
+ rc = TRUE;
|
||||
+ }
|
||||
+ xf_rail_return_window(railWindow);
|
||||
+ return rc;
|
||||
}
|
||||
|
||||
static BOOL xf_rail_notify_icon_common(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
|
||||
@@ -1012,6 +1015,7 @@ static UINT xf_rail_server_local_move_size(RailClientContext* context,
|
||||
else
|
||||
xf_EndLocalMoveSize(xfc, appWindow);
|
||||
|
||||
+ xf_rail_return_window(appWindow);
|
||||
return CHANNEL_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1033,6 +1037,7 @@ static UINT xf_rail_server_min_max_info(RailClientContext* context,
|
||||
minMaxInfo->minTrackHeight, minMaxInfo->maxTrackWidth,
|
||||
minMaxInfo->maxTrackHeight);
|
||||
}
|
||||
+ xf_rail_return_window(appWindow);
|
||||
|
||||
return CHANNEL_RC_OK;
|
||||
}
|
||||
@@ -1190,7 +1195,20 @@ xfAppWindow* xf_rail_get_window(xfContext* xfc, UINT64 id)
|
||||
return NULL;
|
||||
|
||||
if (!xfc->railWindows)
|
||||
- return FALSE;
|
||||
+ return NULL;
|
||||
+
|
||||
+ EnterCriticalSection(&xfc->railWindows->lock);
|
||||
+ xfAppWindow* window = HashTable_GetItemValue(xfc->railWindows, &id);
|
||||
+ if (!window)
|
||||
+ LeaveCriticalSection(&xfc->railWindows->lock);
|
||||
+
|
||||
+ return window;
|
||||
+}
|
||||
+
|
||||
+void xf_rail_return_window(xfAppWindow* window)
|
||||
+{
|
||||
+ if (!window)
|
||||
+ return;
|
||||
|
||||
- return HashTable_GetItemValue(xfc->railWindows, &id);
|
||||
+ LeaveCriticalSection(&window->xfc->railWindows->lock);
|
||||
}
|
||||
diff --git a/client/X11/xf_rail.h b/client/X11/xf_rail.h
|
||||
index c99ed70..5fbc316 100644
|
||||
--- a/client/X11/xf_rail.h
|
||||
+++ b/client/X11/xf_rail.h
|
||||
@@ -35,6 +35,9 @@ void xf_rail_disable_remoteapp_mode(xfContext* xfc);
|
||||
|
||||
xfAppWindow* xf_rail_add_window(xfContext* xfc, UINT64 id, UINT32 x, UINT32 y, UINT32 width,
|
||||
UINT32 height, UINT32 surfaceId);
|
||||
+
|
||||
+void xf_rail_return_window(xfAppWindow* window);
|
||||
+
|
||||
xfAppWindow* xf_rail_get_window(xfContext* xfc, UINT64 id);
|
||||
|
||||
BOOL xf_rail_del_window(xfContext* xfc, UINT64 id);
|
||||
diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c
|
||||
index 9b5b1c4..7e936fe 100644
|
||||
--- a/client/X11/xf_window.c
|
||||
+++ b/client/X11/xf_window.c
|
||||
@@ -1122,22 +1122,33 @@ xfAppWindow* xf_AppWindowFromX11Window(xfContext* xfc, Window wnd)
|
||||
int count;
|
||||
ULONG_PTR* pKeys = NULL;
|
||||
xfAppWindow* appWindow;
|
||||
+
|
||||
+ if (!xfc->railWindows)
|
||||
+ return NULL;
|
||||
+
|
||||
+ EnterCriticalSection(&xfc->railWindows->lock);
|
||||
count = HashTable_GetKeys(xfc->railWindows, &pKeys);
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
- appWindow = xf_rail_get_window(xfc, *(UINT64*)pKeys[index]);
|
||||
+ appWindow = HashTable_GetItemValue(xfc->railWindows, (void*)pKeys[index]);
|
||||
|
||||
if (!appWindow)
|
||||
+ {
|
||||
+ LeaveCriticalSection(&xfc->railWindows->lock);
|
||||
+ free(pKeys);
|
||||
return NULL;
|
||||
+ }
|
||||
|
||||
if (appWindow->handle == wnd)
|
||||
{
|
||||
+ LeaveCriticalSection(&xfc->railWindows->lock);
|
||||
free(pKeys);
|
||||
return appWindow;
|
||||
}
|
||||
}
|
||||
|
||||
+ LeaveCriticalSection(&xfc->railWindows->lock);
|
||||
free(pKeys);
|
||||
return NULL;
|
||||
}
|
||||
diff --git a/client/X11/xf_window.h b/client/X11/xf_window.h
|
||||
index 0f85af1..c7702ed 100644
|
||||
--- a/client/X11/xf_window.h
|
||||
+++ b/client/X11/xf_window.h
|
||||
@@ -187,6 +187,8 @@ void xf_SetWindowMinMaxInfo(xfContext* xfc, xfAppWindow* appWindow, int maxWidth
|
||||
int maxTrackWidth, int maxTrackHeight);
|
||||
void xf_StartLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow, int direction, int x, int y);
|
||||
void xf_EndLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow);
|
||||
+void xf_rail_return_window(xfAppWindow* window);
|
||||
+
|
||||
xfAppWindow* xf_AppWindowFromX11Window(xfContext* xfc, Window wnd);
|
||||
|
||||
#endif /* FREERDP_CLIENT_X11_WINDOW_H */
|
||||
--
|
||||
2.53.0
|
||||
|
||||
360
SOURCES/client-x11-refactor-locking.patch
Normal file
360
SOURCES/client-x11-refactor-locking.patch
Normal file
@ -0,0 +1,360 @@
|
||||
From eeb38c3565473c46da5dea6b43f597064e89b717 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Mon, 27 Apr 2026 20:12:11 +0000
|
||||
Subject: [PATCH] [client,x11] refactor locking
|
||||
|
||||
X11 and railWindows lock must be held at the same time to avoid
|
||||
deadlocking.
|
||||
|
||||
Backport of commit 4ff57b68c2960fa414d03c78ff0e0660be1cc5bd.
|
||||
|
||||
Adapted for 2.11.7: C89 declaration style, direct X11 calls instead
|
||||
of `LogDynAnd*` wrappers, `WINPR_ATTR_UNUSED` removed from
|
||||
`xfAppWindowsLockFrom`/`UnlockFrom`.
|
||||
|
||||
Made-with: Cursor
|
||||
---
|
||||
client/X11/xf_event.c | 24 ++++++++++++------------
|
||||
client/X11/xf_rail.c | 35 +++++++++++++++++++++--------------
|
||||
client/X11/xf_rail.h | 14 ++++++++------
|
||||
client/X11/xf_window.c | 16 +++++++++-------
|
||||
4 files changed, 50 insertions(+), 39 deletions(-)
|
||||
|
||||
diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c
|
||||
index 8801fbd..e1421ad 100644
|
||||
--- a/client/X11/xf_event.c
|
||||
+++ b/client/X11/xf_event.c
|
||||
@@ -357,7 +357,7 @@ static BOOL xf_event_Expose(xfContext* xfc, const XExposeEvent* event, BOOL app)
|
||||
xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
|
||||
if (appWindow)
|
||||
xf_UpdateWindowArea(xfc, appWindow, x, y, w, h);
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -386,7 +386,7 @@ BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window win
|
||||
{
|
||||
/* make sure window exists */
|
||||
xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, window);
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
if (!appWindow)
|
||||
return TRUE;
|
||||
|
||||
@@ -465,7 +465,7 @@ BOOL xf_generic_ButtonEvent(xfContext* xfc, int x, int y, int button, Window win
|
||||
{
|
||||
/* make sure window exists */
|
||||
xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, window);
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
if (!appWindow)
|
||||
return TRUE;
|
||||
|
||||
@@ -576,7 +576,7 @@ static BOOL xf_event_FocusIn(xfContext* xfc, const XFocusInEvent* event, BOOL ap
|
||||
*/
|
||||
if (appWindow)
|
||||
xf_rail_adjust_position(xfc, appWindow);
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
}
|
||||
|
||||
xf_keyboard_focus_in(xfc);
|
||||
@@ -628,7 +628,7 @@ static BOOL xf_event_ClientMessage(xfContext* xfc, const XClientMessageEvent* ev
|
||||
|
||||
if (appWindow)
|
||||
xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_CLOSE);
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
return rc;
|
||||
}
|
||||
else
|
||||
@@ -663,7 +663,7 @@ static BOOL xf_event_EnterNotify(xfContext* xfc, const XEnterWindowEvent* event,
|
||||
|
||||
/* keep track of which window has focus so that we can apply pointer updates */
|
||||
xfc->appWindow = appWindow;
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -683,7 +683,7 @@ static BOOL xf_event_LeaveNotify(xfContext* xfc, const XLeaveWindowEvent* event,
|
||||
/* keep track of which window has focus so that we can apply pointer updates */
|
||||
if (xfc->appWindow == appWindow)
|
||||
xfc->appWindow = NULL;
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -774,7 +774,7 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, const XConfigureEvent* even
|
||||
xf_rail_adjust_position(xfc, appWindow);
|
||||
}
|
||||
}
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
}
|
||||
return xf_pointer_update_scale(xfc);
|
||||
}
|
||||
@@ -799,7 +799,7 @@ static BOOL xf_event_MapNotify(xfContext* xfc, const XMapEvent* event, BOOL app)
|
||||
// xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_RESTORE);
|
||||
appWindow->is_mapped = TRUE;
|
||||
}
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -822,7 +822,7 @@ static BOOL xf_event_UnmapNotify(xfContext* xfc, const XUnmapEvent* event, BOOL
|
||||
|
||||
if (appWindow)
|
||||
appWindow->is_mapped = FALSE;
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -954,7 +954,7 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, const XPropertyEvent* event,
|
||||
rc = gdi_send_suppress_output(xfc->context.gdi, minimized);
|
||||
|
||||
fail:
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
}
|
||||
|
||||
return rc;
|
||||
@@ -1066,7 +1066,7 @@ BOOL xf_event_process(freerdp* instance, const XEvent* event)
|
||||
xfc->appWindow = appWindow;
|
||||
|
||||
BOOL suppress = xf_event_suppress_events(xfc, appWindow, event);
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
if (suppress)
|
||||
return TRUE;
|
||||
}
|
||||
diff --git a/client/X11/xf_rail.c b/client/X11/xf_rail.c
|
||||
index 1e57046..d42b864 100644
|
||||
--- a/client/X11/xf_rail.c
|
||||
+++ b/client/X11/xf_rail.c
|
||||
@@ -101,7 +101,7 @@ void xf_rail_send_activate(xfContext* xfc, Window xwindow, BOOL enabled)
|
||||
xf_SetWindowStyle(xfc, appWindow, 0, 0);
|
||||
|
||||
activate.windowId = appWindow->windowId;
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
|
||||
activate.enabled = enabled;
|
||||
xfc->rail->ClientActivate(xfc->rail, &activate);
|
||||
@@ -213,7 +213,7 @@ static void xf_rail_invalidate_region(xfContext* xfc, REGION16* invalidRegion)
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
- appWindow = xf_rail_get_window(xfc, *(UINT64*)pKeys[index]);
|
||||
+ appWindow = xf_rail_get_window(xfc, *(UINT64*)pKeys[index], FALSE);
|
||||
|
||||
if (appWindow)
|
||||
{
|
||||
@@ -265,7 +265,7 @@ static BOOL xf_rail_window_common(rdpContext* context, const WINDOW_ORDER_INFO*
|
||||
xfContext* xfc = (xfContext*)context;
|
||||
UINT32 fieldFlags = orderInfo->fieldFlags;
|
||||
BOOL position_or_size_updated = FALSE;
|
||||
- xfAppWindow* appWindow = xf_rail_get_window(xfc, orderInfo->windowId);
|
||||
+ xfAppWindow* appWindow = xf_rail_get_window(xfc, orderInfo->windowId, FALSE);
|
||||
|
||||
if (fieldFlags & WINDOW_ORDER_STATE_NEW)
|
||||
{
|
||||
@@ -526,7 +526,7 @@ static BOOL xf_rail_window_common(rdpContext* context, const WINDOW_ORDER_INFO*
|
||||
}*/
|
||||
rc = TRUE;
|
||||
fail:
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -667,7 +667,7 @@ static BOOL xf_rail_window_icon(rdpContext* context, const WINDOW_ORDER_INFO* or
|
||||
BOOL rc = FALSE;
|
||||
xfContext* xfc = (xfContext*)context;
|
||||
BOOL replaceIcon = 0;
|
||||
- xfAppWindow* railWindow = xf_rail_get_window(xfc, orderInfo->windowId);
|
||||
+ xfAppWindow* railWindow = xf_rail_get_window(xfc, orderInfo->windowId, FALSE);
|
||||
|
||||
if (!railWindow)
|
||||
return TRUE;
|
||||
@@ -690,7 +690,7 @@ static BOOL xf_rail_window_icon(rdpContext* context, const WINDOW_ORDER_INFO* or
|
||||
xf_rail_set_window_icon(xfc, railWindow, icon, replaceIcon);
|
||||
rc = TRUE;
|
||||
}
|
||||
- xf_rail_return_window(railWindow);
|
||||
+ xf_rail_return_window(railWindow, FALSE);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -700,7 +700,7 @@ static BOOL xf_rail_window_cached_icon(rdpContext* context, const WINDOW_ORDER_I
|
||||
BOOL rc = FALSE;
|
||||
xfContext* xfc = (xfContext*)context;
|
||||
BOOL replaceIcon = 0;
|
||||
- xfAppWindow* railWindow = xf_rail_get_window(xfc, orderInfo->windowId);
|
||||
+ xfAppWindow* railWindow = xf_rail_get_window(xfc, orderInfo->windowId, FALSE);
|
||||
|
||||
if (!railWindow)
|
||||
return TRUE;
|
||||
@@ -719,7 +719,7 @@ static BOOL xf_rail_window_cached_icon(rdpContext* context, const WINDOW_ORDER_I
|
||||
xf_rail_set_window_icon(xfc, railWindow, icon, replaceIcon);
|
||||
rc = TRUE;
|
||||
}
|
||||
- xf_rail_return_window(railWindow);
|
||||
+ xf_rail_return_window(railWindow, FALSE);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -939,7 +939,7 @@ static UINT xf_rail_server_local_move_size(RailClientContext* context,
|
||||
int direction = 0;
|
||||
Window child_window;
|
||||
xfContext* xfc = (xfContext*)context->custom;
|
||||
- xfAppWindow* appWindow = xf_rail_get_window(xfc, localMoveSize->windowId);
|
||||
+ xfAppWindow* appWindow = xf_rail_get_window(xfc, localMoveSize->windowId, FALSE);
|
||||
|
||||
if (!appWindow)
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
@@ -1020,7 +1020,7 @@ static UINT xf_rail_server_local_move_size(RailClientContext* context,
|
||||
else
|
||||
xf_EndLocalMoveSize(xfc, appWindow);
|
||||
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
return CHANNEL_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1033,7 +1033,7 @@ static UINT xf_rail_server_min_max_info(RailClientContext* context,
|
||||
const RAIL_MINMAXINFO_ORDER* minMaxInfo)
|
||||
{
|
||||
xfContext* xfc = (xfContext*)context->custom;
|
||||
- xfAppWindow* appWindow = xf_rail_get_window(xfc, minMaxInfo->windowId);
|
||||
+ xfAppWindow* appWindow = xf_rail_get_window(xfc, minMaxInfo->windowId, FALSE);
|
||||
|
||||
if (appWindow)
|
||||
{
|
||||
@@ -1042,7 +1042,7 @@ static UINT xf_rail_server_min_max_info(RailClientContext* context,
|
||||
minMaxInfo->minTrackHeight, minMaxInfo->maxTrackWidth,
|
||||
minMaxInfo->maxTrackHeight);
|
||||
}
|
||||
- xf_rail_return_window(appWindow);
|
||||
+ xf_rail_return_window(appWindow, FALSE);
|
||||
|
||||
return CHANNEL_RC_OK;
|
||||
}
|
||||
@@ -1199,13 +1199,20 @@ BOOL xf_rail_del_window(xfContext* xfc, UINT64 id)
|
||||
if (!xfc->railWindows)
|
||||
return FALSE;
|
||||
|
||||
- return HashTable_Remove(xfc->railWindows, &id);
|
||||
+ xf_lock_x11(xfc);
|
||||
+ const BOOL res = HashTable_Remove(xfc->railWindows, &id);
|
||||
+ xf_unlock_x11(xfc);
|
||||
+ return res;
|
||||
}
|
||||
|
||||
-void xf_rail_return_windowFrom(xfAppWindow* window, const char* file, const char* fkt, size_t line)
|
||||
+void xf_rail_return_windowFrom(xfAppWindow* window, BOOL alreadyLocked, const char* file,
|
||||
+ const char* fkt, size_t line)
|
||||
{
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
+ if (alreadyLocked)
|
||||
+ return;
|
||||
+
|
||||
xfAppWindowsUnlockFrom(window->xfc, file, fkt, line);
|
||||
}
|
||||
diff --git a/client/X11/xf_rail.h b/client/X11/xf_rail.h
|
||||
index 83d5fff..a91c1bf 100644
|
||||
--- a/client/X11/xf_rail.h
|
||||
+++ b/client/X11/xf_rail.h
|
||||
@@ -36,14 +36,16 @@ void xf_rail_disable_remoteapp_mode(xfContext* xfc);
|
||||
xfAppWindow* xf_rail_add_window(xfContext* xfc, UINT64 id, UINT32 x, UINT32 y, UINT32 width,
|
||||
UINT32 height, UINT32 surfaceId);
|
||||
|
||||
-#define xf_rail_return_window(window) \
|
||||
- xf_rail_return_windowFrom((window), __FILE__, __func__, __LINE__)
|
||||
-void xf_rail_return_windowFrom(xfAppWindow* window, const char* file, const char* fkt, size_t line);
|
||||
+#define xf_rail_return_window(window, alreadyLocked) \
|
||||
+ xf_rail_return_windowFrom((window), (alreadyLocked), __FILE__, __func__, __LINE__)
|
||||
+void xf_rail_return_windowFrom(xfAppWindow* window, BOOL alreadyLocked, const char* file,
|
||||
+ const char* fkt, size_t line);
|
||||
|
||||
-#define xf_rail_get_window(xfc, id) \
|
||||
- xf_rail_get_windowFrom((xfc), (id), __FILE__, __func__, __LINE__)
|
||||
+#define xf_rail_get_window(xfc, id, alreadyLocked) \
|
||||
+ xf_rail_get_windowFrom((xfc), (id), (alreadyLocked), __FILE__, __func__, __LINE__)
|
||||
|
||||
-xfAppWindow* xf_rail_get_windowFrom(xfContext* xfc, UINT64 id, const char* file, const char* fkt,
|
||||
+xfAppWindow* xf_rail_get_windowFrom(xfContext* xfc, UINT64 id, BOOL alreadyLocked, const char* file,
|
||||
+ const char* fkt,
|
||||
size_t line);
|
||||
|
||||
BOOL xf_rail_del_window(xfContext* xfc, UINT64 id);
|
||||
diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c
|
||||
index 09b4a81..8d09ced 100644
|
||||
--- a/client/X11/xf_window.c
|
||||
+++ b/client/X11/xf_window.c
|
||||
@@ -1070,8 +1070,6 @@ void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y, i
|
||||
if (ay + height > appWindow->windowOffsetY + appWindow->height)
|
||||
height = (appWindow->windowOffsetY + appWindow->height - 1) - ay;
|
||||
|
||||
- xf_lock_x11(xfc);
|
||||
-
|
||||
if (xfc->context.settings->SoftwareGdi)
|
||||
{
|
||||
XPutImage(xfc->display, xfc->primary, appWindow->gc, xfc->image, ax, ay, ax, ay, width,
|
||||
@@ -1081,7 +1079,6 @@ void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y, i
|
||||
XCopyArea(xfc->display, xfc->primary, appWindow->handle, appWindow->gc, ax, ay, width, height,
|
||||
x, y);
|
||||
XFlush(xfc->display);
|
||||
- xf_unlock_x11(xfc);
|
||||
}
|
||||
|
||||
void xf_DestroyWindow(xfContext* xfc, xfAppWindow* appWindow)
|
||||
@@ -1122,8 +1119,8 @@ static xfAppWindow* get_windowUnlocked(xfContext* xfc, UINT64 id)
|
||||
return HashTable_GetItemValue(xfc->railWindows, &id);
|
||||
}
|
||||
|
||||
-xfAppWindow* xf_rail_get_windowFrom(xfContext* xfc, UINT64 id, const char* file, const char* fkt,
|
||||
- size_t line)
|
||||
+xfAppWindow* xf_rail_get_windowFrom(xfContext* xfc, UINT64 id, BOOL alreadyLocked, const char* file,
|
||||
+ const char* fkt, size_t line)
|
||||
{
|
||||
if (!xfc)
|
||||
return NULL;
|
||||
@@ -1131,9 +1128,12 @@ xfAppWindow* xf_rail_get_windowFrom(xfContext* xfc, UINT64 id, const char* file,
|
||||
if (!xfc->railWindows)
|
||||
return NULL;
|
||||
|
||||
- xfAppWindowsLockFrom(xfc, file, fkt, line);
|
||||
+ if (!alreadyLocked)
|
||||
+ xfAppWindowsLockFrom(xfc, file, fkt, line);
|
||||
+
|
||||
xfAppWindow* window = get_windowUnlocked(xfc, id);
|
||||
- if (!window)
|
||||
+
|
||||
+ if (!window && !alreadyLocked)
|
||||
xfAppWindowsUnlockFrom(xfc, file, fkt, line);
|
||||
|
||||
return window;
|
||||
@@ -1176,6 +1176,7 @@ xfAppWindow* xf_AppWindowFromX11WindowFrom(xfContext* xfc, Window wnd, const cha
|
||||
void xfAppWindowsLockFrom(xfContext* xfc, const char* file, const char* fkt, size_t line)
|
||||
{
|
||||
WINPR_ASSERT(xfc);
|
||||
+ xf_lock_x11(xfc);
|
||||
EnterCriticalSection(&xfc->railWindows->lock);
|
||||
}
|
||||
|
||||
@@ -1183,4 +1184,5 @@ void xfAppWindowsUnlockFrom(xfContext* xfc, const char* file, const char* fkt, s
|
||||
{
|
||||
WINPR_ASSERT(xfc);
|
||||
LeaveCriticalSection(&xfc->railWindows->lock);
|
||||
+ xf_unlock_x11(xfc);
|
||||
}
|
||||
--
|
||||
2.53.0
|
||||
|
||||
@ -0,0 +1,57 @@
|
||||
From 947feeadfddf01d30dda5aa16ebc335bfcc23ae0 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Tue, 29 Apr 2026 13:42:00 +0000
|
||||
Subject: [PATCH] [codec,clear] Update CLEAR_GLYPH_ENTRY::count after alloc
|
||||
|
||||
Backport of commit c49d1ad43b8c7b32794d0250f2623c2dccd7ef25.
|
||||
|
||||
Adapted for 2.11.7: uses GetBytesPerPixel instead of FreeRDPGetBytesPerPixel,
|
||||
plain realloc instead of winpr_aligned_recalloc; overflow checks match upstream
|
||||
(size_t count, hlimit / exceeded logging); glyphEntry->count set via (UINT32)cast
|
||||
after successful realloc.
|
||||
|
||||
Made-with: Cursor
|
||||
---
|
||||
libfreerdp/codec/clear.c | 22 +++++++++++++++++-----
|
||||
1 file changed, 17 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/libfreerdp/codec/clear.c b/libfreerdp/codec/clear.c
|
||||
--- a/libfreerdp/codec/clear.c
|
||||
+++ b/libfreerdp/codec/clear.c
|
||||
@@ -979,20 +979,31 @@
|
||||
{
|
||||
const UINT32 bpp = GetBytesPerPixel(clear->format);
|
||||
CLEAR_GLYPH_ENTRY* glyphEntry = &(clear->GlyphCache[glyphIndex]);
|
||||
- glyphEntry->count = nWidth * nHeight;
|
||||
+ const size_t count = 1ull * nWidth * nHeight;
|
||||
+ const size_t hlimit = SIZE_MAX / ((nWidth > 0) ? nWidth : 1);
|
||||
+ if ((nWidth == 0) || (nHeight == 0) || (hlimit < nHeight))
|
||||
+ {
|
||||
+ const char* exceeded = (hlimit < nHeight) ? "within" : "outside";
|
||||
+ WLog_ERR(TAG,
|
||||
+ "CLEARCODEC_FLAG_GLYPH_INDEX: nWidth=%" PRIu32 ", nHeight=%" PRIu32
|
||||
+ ", nWidth * nHeight is %s allowed range",
|
||||
+ nWidth, nHeight, exceeded);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
|
||||
- if (glyphEntry->count > glyphEntry->size)
|
||||
+ if (count > glyphEntry->size)
|
||||
{
|
||||
BYTE* tmp;
|
||||
- tmp = realloc(glyphEntry->pixels, 1ull * glyphEntry->count * bpp);
|
||||
+ tmp = realloc(glyphEntry->pixels, 1ull * count * bpp);
|
||||
|
||||
if (!tmp)
|
||||
{
|
||||
- WLog_ERR(TAG, "glyphEntry->pixels realloc %" PRIu32 " failed!",
|
||||
- glyphEntry->count * bpp);
|
||||
+ WLog_ERR(TAG, "glyphEntry->pixels realloc %" PRIuz " failed!",
|
||||
+ count * bpp);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+ glyphEntry->count = (UINT32)count;
|
||||
glyphEntry->size = glyphEntry->count;
|
||||
glyphEntry->pixels = (UINT32*)tmp;
|
||||
}
|
||||
218
SOURCES/codec-dsp-add-format-checks.patch
Normal file
218
SOURCES/codec-dsp-add-format-checks.patch
Normal file
@ -0,0 +1,218 @@
|
||||
From 74ff8a097c3606710327e3af2863aa52d2dac79e Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Tue, 29 Apr 2026 15:10:00 +0000
|
||||
Subject: [PATCH] [codec,dsp] add format checks
|
||||
|
||||
Backport of commit 03b48b3601d867afccac1cdc6081de7a275edce7.
|
||||
|
||||
Adapted for 2.11.x: uses `context->format` instead of
|
||||
`context->common.format`, no `WINPR_RESTRICT`, added
|
||||
`#include <winpr/assert.h>`. Kept C89 declaration style in
|
||||
`freerdp_dsp_decode_mp3` and `freerdp_dsp_encode_mp3`. Omitted
|
||||
LAME/mp3 variable modernization. DVI_ADPCM block in
|
||||
`freerdp_dsp_context_reset` omits FramesPerPacket sizing from upstream 3.x
|
||||
but adds `Stream_SetPosition(context->buffer, 0)` after validation (same
|
||||
intent as upstream `Stream_ResetPosition`). `freerdp_dsp_decode_ima_adpcm`
|
||||
matches upstream order: validate format before locals; `out_size` uses
|
||||
`size * 4ull`. `Stream_BufferAs` replaced with
|
||||
`Stream_Buffer` cast. `nullptr` replaced with `NULL`.
|
||||
|
||||
Made-with: Cursor
|
||||
---
|
||||
libfreerdp/codec/dsp.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 93 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/libfreerdp/codec/dsp.c b/libfreerdp/codec/dsp.c
|
||||
index a18d044..e79911d 100644
|
||||
--- a/libfreerdp/codec/dsp.c
|
||||
+++ b/libfreerdp/codec/dsp.c
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
+#include <winpr/assert.h>
|
||||
|
||||
#include <freerdp/types.h>
|
||||
#include <freerdp/log.h>
|
||||
@@ -329,13 +330,30 @@
|
||||
return (UINT16)d;
|
||||
}
|
||||
|
||||
+static BOOL valid_ima_adpcm_format(const FREERDP_DSP_CONTEXT* context)
|
||||
+{
|
||||
+ WINPR_ASSERT(context);
|
||||
+ if (context->format.wFormatTag != WAVE_FORMAT_DVI_ADPCM)
|
||||
+ return FALSE;
|
||||
+ if (context->format.nBlockAlign <= 4ULL)
|
||||
+ return FALSE;
|
||||
+ if (context->format.nChannels < 1)
|
||||
+ return FALSE;
|
||||
+ if (context->format.wBitsPerSample == 0)
|
||||
+ return FALSE;
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
static BOOL freerdp_dsp_decode_ima_adpcm(FREERDP_DSP_CONTEXT* context, const BYTE* src, size_t size,
|
||||
wStream* out)
|
||||
{
|
||||
+ if (!valid_ima_adpcm_format(context))
|
||||
+ return FALSE;
|
||||
+
|
||||
BYTE* dst;
|
||||
BYTE sample;
|
||||
UINT16 decoded;
|
||||
- size_t out_size = size * 4;
|
||||
+ size_t out_size = size * 4ull;
|
||||
UINT32 channel;
|
||||
const UINT32 block_size = context->format.nBlockAlign;
|
||||
const UINT32 channels = context->format.nChannels;
|
||||
@@ -464,6 +482,20 @@
|
||||
#endif
|
||||
|
||||
#if defined(WITH_LAME)
|
||||
+static BOOL valid_mp3_format(const FREERDP_DSP_CONTEXT* context)
|
||||
+{
|
||||
+ WINPR_ASSERT(context);
|
||||
+ if (context->format.wFormatTag != WAVE_FORMAT_MPEGLAYER3)
|
||||
+ return FALSE;
|
||||
+ if (context->format.nChannels < 1)
|
||||
+ return FALSE;
|
||||
+ if (context->format.wBitsPerSample == 0)
|
||||
+ return FALSE;
|
||||
+ if (context->format.nSamplesPerSec == 0)
|
||||
+ return FALSE;
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
static BOOL freerdp_dsp_decode_mp3(FREERDP_DSP_CONTEXT* context, const BYTE* src, size_t size,
|
||||
wStream* out)
|
||||
{
|
||||
@@ -474,6 +506,8 @@
|
||||
|
||||
if (!context || !src || !out)
|
||||
return FALSE;
|
||||
+ if (!valid_mp3_format(context))
|
||||
+ return FALSE;
|
||||
|
||||
buffer_size = 2 * context->format.nChannels * context->format.nSamplesPerSec;
|
||||
|
||||
@@ -509,6 +543,9 @@
|
||||
if (!context || !src || !out)
|
||||
return FALSE;
|
||||
|
||||
+ if (!valid_mp3_format(context))
|
||||
+ return FALSE;
|
||||
+
|
||||
samples_per_channel = size / context->format.nChannels / context->format.wBitsPerSample / 8;
|
||||
|
||||
/* Ensure worst case buffer size for mp3 stream taken from LAME header */
|
||||
@@ -716,6 +753,10 @@
|
||||
BYTE encoded;
|
||||
size_t out_size;
|
||||
size_t align;
|
||||
+
|
||||
+ if (!valid_ima_adpcm_format(context))
|
||||
+ return FALSE;
|
||||
+
|
||||
out_size = size / 2;
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(out, size))
|
||||
@@ -788,6 +829,20 @@
|
||||
|
||||
static const INT32 ms_adpcm_coeffs2[7] = { 0, -256, 0, 64, 0, -208, -232 };
|
||||
|
||||
+static BOOL valid_ms_adpcm_format(const FREERDP_DSP_CONTEXT* context)
|
||||
+{
|
||||
+ WINPR_ASSERT(context);
|
||||
+ if (context->format.wFormatTag != WAVE_FORMAT_ADPCM)
|
||||
+ return FALSE;
|
||||
+ if (context->format.nBlockAlign <= 4ULL)
|
||||
+ return FALSE;
|
||||
+ if (context->format.nChannels < 1)
|
||||
+ return FALSE;
|
||||
+ if (context->format.wBitsPerSample == 0)
|
||||
+ return FALSE;
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
static INLINE INT16 freerdp_dsp_decode_ms_adpcm_sample(ADPCM* adpcm, BYTE sample, int channel)
|
||||
{
|
||||
INT8 nibble;
|
||||
@@ -819,6 +874,9 @@
|
||||
BYTE* dst;
|
||||
BYTE sample;
|
||||
const size_t out_size = size * 4;
|
||||
+
|
||||
+ if (!valid_ms_adpcm_format(context))
|
||||
+ return FALSE;
|
||||
const UINT32 channels = context->format.nChannels;
|
||||
const UINT32 block_size = context->format.nBlockAlign;
|
||||
|
||||
@@ -947,6 +1005,10 @@
|
||||
INT32 sample;
|
||||
size_t out_size;
|
||||
const size_t step = 8 + ((context->format.nChannels > 1) ? 4 : 0);
|
||||
+
|
||||
+ if (!valid_ms_adpcm_format(context))
|
||||
+ return FALSE;
|
||||
+
|
||||
out_size = size / 2;
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(out, size))
|
||||
@@ -1308,6 +1370,28 @@
|
||||
return FALSE;
|
||||
|
||||
context->format = *targetFormat;
|
||||
+
|
||||
+ switch (context->format.wFormatTag)
|
||||
+ {
|
||||
+#if defined(WITH_LAME)
|
||||
+ case WAVE_FORMAT_MPEGLAYER3:
|
||||
+ if (!valid_mp3_format(context))
|
||||
+ return FALSE;
|
||||
+ break;
|
||||
+#endif
|
||||
+ case WAVE_FORMAT_ADPCM:
|
||||
+ if (!valid_ms_adpcm_format(context))
|
||||
+ return FALSE;
|
||||
+ break;
|
||||
+ case WAVE_FORMAT_DVI_ADPCM:
|
||||
+ if (!valid_ima_adpcm_format(context))
|
||||
+ return FALSE;
|
||||
+ Stream_SetPosition(context->buffer, 0);
|
||||
+ break;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
#if defined(WITH_FAAD2)
|
||||
context->faadSetup = FALSE;
|
||||
#endif
|
||||
@@ -1328,19 +1412,24 @@
|
||||
|
||||
cfg = faacEncGetCurrentConfiguration(context->faac);
|
||||
cfg->bitRate = 10000;
|
||||
- faacEncSetConfiguration(context->faac, cfg);
|
||||
+ {
|
||||
+ const int frc = faacEncSetConfiguration(context->faac, cfg);
|
||||
+ if (frc <= 0)
|
||||
+ return FALSE;
|
||||
+ }
|
||||
}
|
||||
|
||||
#endif
|
||||
#if defined(WITH_SOXR)
|
||||
{
|
||||
soxr_io_spec_t iospec = soxr_io_spec(SOXR_INT16, SOXR_INT16);
|
||||
- soxr_error_t error;
|
||||
+ soxr_error_t error = NULL;
|
||||
+
|
||||
soxr_delete(context->sox);
|
||||
context->sox = soxr_create(context->format.nSamplesPerSec, targetFormat->nSamplesPerSec,
|
||||
targetFormat->nChannels, &error, &iospec, NULL, NULL);
|
||||
|
||||
- if (!context->sox || (error != 0))
|
||||
+ if (!context->sox || (error != NULL))
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
237
SOURCES/codec-dsp-fix-array-bounds-checks.patch
Normal file
237
SOURCES/codec-dsp-fix-array-bounds-checks.patch
Normal file
@ -0,0 +1,237 @@
|
||||
From aaf333862fb54d4cfc19a1866b76500d86679719 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Tue, 28 Apr 2026 04:41:15 +0000
|
||||
Subject: [PATCH] [codec,dsp] fix array bounds checks
|
||||
|
||||
Backport of commit 16df2300e1e3f5a51f68fb1626429e58b531b7c8.
|
||||
|
||||
Adapted for 2.11.x: uses C89 declaration style (variables declared
|
||||
at top of scope, new variables wrapped in blocks), no
|
||||
`WINPR_RESTRICT`, kept `int channel` in decode function,
|
||||
`dsp_encode_ima_adpcm_sample` keeps `int channel`.
|
||||
|
||||
Made-with: Cursor
|
||||
---
|
||||
libfreerdp/codec/dsp.c | 91 +++++++++++++++++++++++++++++++++++++-----
|
||||
1 file changed, 82 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/libfreerdp/codec/dsp.c b/libfreerdp/codec/dsp.c
|
||||
index e79911d..6d4f780 100644
|
||||
--- a/libfreerdp/codec/dsp.c
|
||||
+++ b/libfreerdp/codec/dsp.c
|
||||
@@ -297,7 +297,16 @@ static UINT16 dsp_decode_ima_adpcm_sample(ADPCM* adpcm, unsigned int channel, BY
|
||||
{
|
||||
INT32 ss;
|
||||
INT32 d;
|
||||
- ss = ima_step_size_table[adpcm->ima.last_step[channel]];
|
||||
+ INT16 offset;
|
||||
+
|
||||
+ WINPR_ASSERT(channel < ARRAYSIZE(adpcm->ima.last_step));
|
||||
+ WINPR_ASSERT(channel < ARRAYSIZE(adpcm->ima.last_sample));
|
||||
+
|
||||
+ offset = adpcm->ima.last_step[channel];
|
||||
+ WINPR_ASSERT(offset >= 0);
|
||||
+ WINPR_ASSERT(offset < ARRAYSIZE(ima_step_size_table));
|
||||
+
|
||||
+ ss = ima_step_size_table[offset];
|
||||
d = (ss >> 3);
|
||||
|
||||
if (sample & 1)
|
||||
@@ -320,6 +329,8 @@ static UINT16 dsp_decode_ima_adpcm_sample(ADPCM* adpcm, unsigned int channel, BY
|
||||
d = 32767;
|
||||
|
||||
adpcm->ima.last_sample[channel] = (INT16)d;
|
||||
+
|
||||
+ WINPR_ASSERT(sample < ARRAYSIZE(ima_step_index_table));
|
||||
adpcm->ima.last_step[channel] += ima_step_index_table[sample];
|
||||
|
||||
if (adpcm->ima.last_step[channel] < 0)
|
||||
@@ -368,6 +379,9 @@ static BOOL freerdp_dsp_decode_ima_adpcm(FREERDP_DSP_CONTEXT* context, const BYT
|
||||
{
|
||||
if (size % block_size == 0)
|
||||
{
|
||||
+ if (size < 4)
|
||||
+ return FALSE;
|
||||
+
|
||||
context->adpcm.ima.last_sample[0] =
|
||||
(INT16)(((UINT16)(*src)) | (((UINT16)(*(src + 1))) << 8));
|
||||
context->adpcm.ima.last_step[0] = (INT16)(*(src + 2));
|
||||
@@ -377,6 +391,8 @@ static BOOL freerdp_dsp_decode_ima_adpcm(FREERDP_DSP_CONTEXT* context, const BYT
|
||||
|
||||
if (channels > 1)
|
||||
{
|
||||
+ if (size < 4)
|
||||
+ return FALSE;
|
||||
context->adpcm.ima.last_sample[1] =
|
||||
(INT16)(((UINT16)(*src)) | (((UINT16)(*(src + 1))) << 8));
|
||||
context->adpcm.ima.last_step[1] = (INT16)(*(src + 2));
|
||||
@@ -388,6 +404,8 @@ static BOOL freerdp_dsp_decode_ima_adpcm(FREERDP_DSP_CONTEXT* context, const BYT
|
||||
|
||||
if (channels > 1)
|
||||
{
|
||||
+ if (size < 8)
|
||||
+ return FALSE;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
channel = (i < 4 ? 0 : 1);
|
||||
@@ -407,6 +425,8 @@ static BOOL freerdp_dsp_decode_ima_adpcm(FREERDP_DSP_CONTEXT* context, const BYT
|
||||
}
|
||||
else
|
||||
{
|
||||
+ if (size < 1)
|
||||
+ return FALSE;
|
||||
sample = ((*src) & 0x0f);
|
||||
decoded = dsp_decode_ima_adpcm_sample(&context->adpcm, 0, sample);
|
||||
*dst++ = (decoded & 0xFF);
|
||||
@@ -687,7 +707,16 @@ static BYTE dsp_encode_ima_adpcm_sample(ADPCM* adpcm, int channel, INT16 sample)
|
||||
INT32 ss;
|
||||
BYTE enc;
|
||||
INT32 diff;
|
||||
- ss = ima_step_size_table[adpcm->ima.last_step[channel]];
|
||||
+ INT16 offset;
|
||||
+
|
||||
+ WINPR_ASSERT(channel < ARRAYSIZE(adpcm->ima.last_step));
|
||||
+ WINPR_ASSERT(channel < ARRAYSIZE(adpcm->ima.last_sample));
|
||||
+
|
||||
+ offset = adpcm->ima.last_step[channel];
|
||||
+ WINPR_ASSERT(offset >= 0);
|
||||
+ WINPR_ASSERT(offset < ARRAYSIZE(ima_step_size_table));
|
||||
+
|
||||
+ ss = ima_step_size_table[offset];
|
||||
d = e = sample - adpcm->ima.last_sample[channel];
|
||||
diff = ss >> 3;
|
||||
enc = 0;
|
||||
@@ -733,6 +762,8 @@ static BYTE dsp_encode_ima_adpcm_sample(ADPCM* adpcm, int channel, INT16 sample)
|
||||
diff = 32767;
|
||||
|
||||
adpcm->ima.last_sample[channel] = (INT16)diff;
|
||||
+
|
||||
+ WINPR_ASSERT(enc < ARRAYSIZE(ima_step_index_table));
|
||||
adpcm->ima.last_step[channel] += ima_step_index_table[enc];
|
||||
|
||||
if (adpcm->ima.last_step[channel] < 0)
|
||||
@@ -847,10 +878,24 @@ static INLINE INT16 freerdp_dsp_decode_ms_adpcm_sample(ADPCM* adpcm, BYTE sample
|
||||
{
|
||||
INT8 nibble;
|
||||
INT32 presample;
|
||||
+ BYTE predictor;
|
||||
+ INT32 coeff1 = 0;
|
||||
+ INT32 coeff2 = 0;
|
||||
+
|
||||
+ WINPR_ASSERT(channel < ARRAYSIZE(adpcm->ms.sample1));
|
||||
+ WINPR_ASSERT(channel < ARRAYSIZE(adpcm->ms.sample2));
|
||||
+ WINPR_ASSERT(channel < ARRAYSIZE(adpcm->ms.delta));
|
||||
+ WINPR_ASSERT(channel < ARRAYSIZE(adpcm->ms.predictor));
|
||||
+
|
||||
nibble = (sample & 0x08 ? (INT8)sample - 16 : (INT8)sample);
|
||||
- presample = ((adpcm->ms.sample1[channel] * ms_adpcm_coeffs1[adpcm->ms.predictor[channel]]) +
|
||||
- (adpcm->ms.sample2[channel] * ms_adpcm_coeffs2[adpcm->ms.predictor[channel]])) /
|
||||
- 256;
|
||||
+ predictor = adpcm->ms.predictor[channel];
|
||||
+ if (predictor < ARRAYSIZE(ms_adpcm_coeffs1))
|
||||
+ coeff1 = ms_adpcm_coeffs1[predictor];
|
||||
+
|
||||
+ if (predictor < ARRAYSIZE(ms_adpcm_coeffs2))
|
||||
+ coeff2 = ms_adpcm_coeffs2[predictor];
|
||||
+ presample =
|
||||
+ ((adpcm->ms.sample1[channel] * coeff1) + (adpcm->ms.sample2[channel] * coeff2)) / 256;
|
||||
presample += nibble * adpcm->ms.delta[channel];
|
||||
|
||||
if (presample > 32767)
|
||||
@@ -860,7 +905,14 @@ static INLINE INT16 freerdp_dsp_decode_ms_adpcm_sample(ADPCM* adpcm, BYTE sample
|
||||
|
||||
adpcm->ms.sample2[channel] = adpcm->ms.sample1[channel];
|
||||
adpcm->ms.sample1[channel] = presample;
|
||||
- adpcm->ms.delta[channel] = adpcm->ms.delta[channel] * ms_adpcm_adaptation_table[sample] / 256;
|
||||
+
|
||||
+ {
|
||||
+ INT32 tableval = 0;
|
||||
+ if (sample < ARRAYSIZE(ms_adpcm_adaptation_table))
|
||||
+ tableval = ms_adpcm_adaptation_table[sample];
|
||||
+
|
||||
+ adpcm->ms.delta[channel] = adpcm->ms.delta[channel] * tableval / 256;
|
||||
+ }
|
||||
|
||||
if (adpcm->ms.delta[channel] < 16)
|
||||
adpcm->ms.delta[channel] = 16;
|
||||
@@ -891,6 +943,9 @@ static BOOL freerdp_dsp_decode_ms_adpcm(FREERDP_DSP_CONTEXT* context, const BYTE
|
||||
{
|
||||
if (channels > 1)
|
||||
{
|
||||
+ if (size < 14)
|
||||
+ return FALSE;
|
||||
+
|
||||
context->adpcm.ms.predictor[0] = *src++;
|
||||
context->adpcm.ms.predictor[1] = *src++;
|
||||
context->adpcm.ms.delta[0] = read_int16(src);
|
||||
@@ -917,6 +972,9 @@ static BOOL freerdp_dsp_decode_ms_adpcm(FREERDP_DSP_CONTEXT* context, const BYTE
|
||||
}
|
||||
else
|
||||
{
|
||||
+ if (size < 7)
|
||||
+ return FALSE;
|
||||
+
|
||||
context->adpcm.ms.predictor[0] = *src++;
|
||||
context->adpcm.ms.delta[0] = read_int16(src);
|
||||
src += 2;
|
||||
@@ -934,12 +992,16 @@ static BOOL freerdp_dsp_decode_ms_adpcm(FREERDP_DSP_CONTEXT* context, const BYTE
|
||||
|
||||
if (channels > 1)
|
||||
{
|
||||
+ if (size < 1)
|
||||
+ return FALSE;
|
||||
sample = *src++;
|
||||
size--;
|
||||
write_int16(dst, freerdp_dsp_decode_ms_adpcm_sample(&context->adpcm, sample >> 4, 0));
|
||||
dst += 2;
|
||||
write_int16(dst, freerdp_dsp_decode_ms_adpcm_sample(&context->adpcm, sample & 0x0F, 1));
|
||||
dst += 2;
|
||||
+ if (size < 1)
|
||||
+ return FALSE;
|
||||
sample = *src++;
|
||||
size--;
|
||||
write_int16(dst, freerdp_dsp_decode_ms_adpcm_sample(&context->adpcm, sample >> 4, 0));
|
||||
@@ -949,6 +1011,8 @@ static BOOL freerdp_dsp_decode_ms_adpcm(FREERDP_DSP_CONTEXT* context, const BYTE
|
||||
}
|
||||
else
|
||||
{
|
||||
+ if (size < 1)
|
||||
+ return FALSE;
|
||||
sample = *src++;
|
||||
size--;
|
||||
write_int16(dst, freerdp_dsp_decode_ms_adpcm_sample(&context->adpcm, sample >> 4, 0));
|
||||
@@ -962,10 +1026,16 @@ static BOOL freerdp_dsp_decode_ms_adpcm(FREERDP_DSP_CONTEXT* context, const BYTE
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
-static BYTE freerdp_dsp_encode_ms_adpcm_sample(ADPCM* adpcm, INT32 sample, int channel)
|
||||
+static BYTE freerdp_dsp_encode_ms_adpcm_sample(ADPCM* adpcm, INT32 sample, size_t channel)
|
||||
{
|
||||
INT32 presample;
|
||||
INT32 errordelta;
|
||||
+
|
||||
+ WINPR_ASSERT(channel < ARRAYSIZE(adpcm->ms.sample1));
|
||||
+ WINPR_ASSERT(channel < ARRAYSIZE(adpcm->ms.sample2));
|
||||
+ WINPR_ASSERT(channel < ARRAYSIZE(adpcm->ms.delta));
|
||||
+ WINPR_ASSERT(channel < ARRAYSIZE(adpcm->ms.predictor));
|
||||
+
|
||||
presample = ((adpcm->ms.sample1[channel] * ms_adpcm_coeffs1[adpcm->ms.predictor[channel]]) +
|
||||
(adpcm->ms.sample2[channel] * ms_adpcm_coeffs2[adpcm->ms.predictor[channel]])) /
|
||||
256;
|
||||
@@ -988,8 +1058,11 @@ static BYTE freerdp_dsp_encode_ms_adpcm_sample(ADPCM* adpcm, INT32 sample, int c
|
||||
|
||||
adpcm->ms.sample2[channel] = adpcm->ms.sample1[channel];
|
||||
adpcm->ms.sample1[channel] = presample;
|
||||
- adpcm->ms.delta[channel] =
|
||||
- adpcm->ms.delta[channel] * ms_adpcm_adaptation_table[(((BYTE)errordelta) & 0x0F)] / 256;
|
||||
+ {
|
||||
+ const size_t offset = (((BYTE)errordelta) & 0x0F);
|
||||
+ WINPR_ASSERT(offset < ARRAYSIZE(ms_adpcm_adaptation_table));
|
||||
+ adpcm->ms.delta[channel] = adpcm->ms.delta[channel] * ms_adpcm_adaptation_table[offset] / 256;
|
||||
+ }
|
||||
|
||||
if (adpcm->ms.delta[channel] < 16)
|
||||
adpcm->ms.delta[channel] = 16;
|
||||
--
|
||||
2.53.0
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
|
||||
Name: freerdp
|
||||
Version: 2.11.7
|
||||
Release: 7%{?dist}
|
||||
Release: 9%{?dist}
|
||||
Epoch: 2
|
||||
Summary: Free implementation of the Remote Desktop Protocol (RDP)
|
||||
License: ASL 2.0
|
||||
@ -154,6 +154,43 @@ Patch32: codec-clear-update-CLEAR_VBAR_ENTRY-size-after-alloc.patch
|
||||
Patch33: codec-progressive-fail-progressive_rfx_quant_sub-on-invalid-values.patch
|
||||
Patch34: codec-progressive-fix-underflow-guard-in-progressive_rfx_quant_sub.patch
|
||||
|
||||
# CVE-2026-26986
|
||||
# https://github.com/FreeRDP/FreeRDP/commit/b4f0f0a18fe53aa8d47d062f91471f4e9c5e0d51
|
||||
Patch35: client-x11-fix-xf_rail_window_common-cleanup.patch
|
||||
|
||||
# CVE-2026-27951
|
||||
# https://github.com/FreeRDP/FreeRDP/commit/118afc0b954ba9d5632b7836ad24e454555ed113
|
||||
Patch36: allocations-fix-growth-of-preallocated-buffers.patch
|
||||
|
||||
# CVE-2026-29775
|
||||
# https://github.com/FreeRDP/FreeRDP/commit/ffad58fd2b329efd81a3239e9d7e3c927b8e503f
|
||||
# https://github.com/FreeRDP/FreeRDP/commit/8270e0bb3d6726c947d57c93ba9caa92a052b557
|
||||
Patch37: cache-bitmap-overallocate-bitmap-cache.patch
|
||||
Patch38: cache-bitmap-initialize-overallocated-bitmap-cache-extra-slot.patch
|
||||
|
||||
# CVE-2026-31884
|
||||
# https://github.com/FreeRDP/FreeRDP/commit/03b48b3601d867afccac1cdc6081de7a275edce7
|
||||
Patch39: codec-dsp-add-format-checks.patch
|
||||
|
||||
# CVE-2026-31883
|
||||
# CVE-2026-31885
|
||||
# https://github.com/FreeRDP/FreeRDP/commit/16df2300e1e3f5a51f68fb1626429e58b531b7c8
|
||||
Patch40: codec-dsp-fix-array-bounds-checks.patch
|
||||
|
||||
# CVE-2026-33985
|
||||
# https://github.com/FreeRDP/FreeRDP/commit/c49d1ad43b8c7b32794d0250f2623c2dccd7ef25
|
||||
Patch41: codec-clear-update-clear_glyph_entry-count-after-alloc.patch
|
||||
|
||||
# CVE-2026-25952
|
||||
# https://github.com/FreeRDP/FreeRDP/commit/1994e9844212a6dfe0ff12309fef520e888986b5
|
||||
# https://github.com/FreeRDP/FreeRDP/commit/78fd7f580d5f9e6d9d582d82e5ea96003844fbdf
|
||||
# https://github.com/FreeRDP/FreeRDP/commit/4ff57b68c2960fa414d03c78ff0e0660be1cc5bd
|
||||
# https://github.com/FreeRDP/FreeRDP/commit/a278ff74117444c635c50ffa5084ecf517171f5a
|
||||
Patch42: client-x11-lock-appwindow.patch
|
||||
Patch43: client-x11-improve-rails-window-locking.patch
|
||||
Patch44: client-x11-refactor-locking.patch
|
||||
Patch45: client-x11-fix-deadlock-on-output-expose.patch
|
||||
|
||||
BuildRequires: gcc
|
||||
BuildRequires: gcc-c++
|
||||
BuildRequires: alsa-lib-devel
|
||||
@ -411,6 +448,21 @@ find %{buildroot} -name "*.a" -delete
|
||||
%{_libdir}/pkgconfig/winpr-tools2.pc
|
||||
|
||||
%changelog
|
||||
* Tue May 05 2026 Ondrej Holy <oholy@redhat.com> - 2:2.11.7-9
|
||||
- Lock appWindow to fix use-after-free in RAIL mode (CVE-2026-25952)
|
||||
Resolves: RHEL-159850
|
||||
|
||||
* Tue Apr 28 2026 Ondrej Holy <oholy@redhat.com> - 2:2.11.7-8
|
||||
- Fix double free in xf_rail_window_common cleanup (CVE-2026-26986)
|
||||
- Fix growth of preallocated buffers (CVE-2026-27951)
|
||||
- Fix heap-buffer-overflow in bitmap_cache_put (CVE-2026-29775)
|
||||
- Add DSP format checks (CVE-2026-31884)
|
||||
- Fix DSP array bounds checks (CVE-2026-31883)
|
||||
- Fix DSP array bounds checks (CVE-2026-31885)
|
||||
- Update CLEAR_GLYPH_ENTRY::count after alloc (CVE-2026-33985)
|
||||
Resolves: RHEL-159806, RHEL-155468, RHEL-161037, RHEL-161472
|
||||
Resolves: RHEL-161508, RHEL-161075, RHEL-167794
|
||||
|
||||
* Fri Apr 10 2026 Ondrej Holy <oholy@redhat.com> - 2:2.11.7-7
|
||||
- Update CLEAR_VBAR_ENTRY size after alloc (CVE-2026-33984)
|
||||
- Fail progressive_rfx_quant_sub on invalid values (CVE-2026-33983)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user