gapplication: Validate types of well-known platform data keys

The platform data comes from the parent process, which should normally
be considered trusted (if we don’t trust it, it can do all sorts of
other things to mess this process up, such as setting
`LD_LIBRARY_PATH`).

However, it can also come from any process which calls `CommandLine`
over D-Bus, so always has to be able to handle untrusted input. In
particular, `v`-typed `GVariant`s must always have their dynamic type
validated before having values of a static type retrieved from them.

Includes unit tests.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #1904
This commit is contained in:
Philip Withnall
2022-11-10 23:12:49 +00:00
parent eb0d9e709a
commit c0eef5e226
3 changed files with 50 additions and 4 deletions

View File

@@ -95,8 +95,11 @@ struct _GApplicationClass
gchar ***arguments,
int *exit_status);
/* @platform_data comes from an external process and is untrusted. All value types
* must be validated before being used. */
void (* before_emit) (GApplication *application,
GVariant *platform_data);
/* Same as for @before_emit. */
void (* after_emit) (GApplication *application,
GVariant *platform_data);
void (* add_platform_data) (GApplication *application,