File xdg-desktop-portal-CVE-2024-32462.patch of Package xdg-desktop-portal.34042
Author: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
Date: Wed Apr 17 09:30:09 2024 -0300
background: Improve validation of commandline option
Check that the first commandline item doesn't start with whitespaces or
a hyphen.
Also sneakily plug a memory leak, g_variant_get_strv() is transfer-
container. Switch to g_autofree on the variable.
Mitigates: CVE-2024-32462
diff -Nura xdg-desktop-portal-1.8.0/src/background.c xdg-desktop-portal-1.8.0_new/src/background.c
--- xdg-desktop-portal-1.8.0/src/background.c 2020-03-13 20:38:51.000000000 +0800
+++ xdg-desktop-portal-1.8.0_new/src/background.c 2024-05-27 14:09:45.170398743 +0800
@@ -358,7 +358,7 @@
GError **error)
{
gsize length;
- const char **strv = g_variant_get_strv (value, &length);
+ g_autofree const char **strv = g_variant_get_strv (value, &length);
if (strv[0] == NULL)
{
@@ -373,6 +373,13 @@
"Not accepting overly long commandlines");
return FALSE;
}
+
+ if (*strv[0] == ' ' || *strv[0] == '-')
+ {
+ g_set_error (error, XDG_DESKTOP_PORTAL_ERROR, XDG_DESKTOP_PORTAL_ERROR_INVALID_ARGUMENT,
+ "First commandline item can't start with whitespace nor hyphens");
+ return FALSE;
+ }
if (length > 100)
{