| 1 | From 31e0d403ba635dbbacbfbff74295e5db02558d76 Mon Sep 17 00:00:00 2001 |
| 2 | From: Philip Withnall <pwithnall@endlessos.org> |
| 3 | Date: Wed, 10 Feb 2021 21:19:30 +0000 |
| 4 | Subject: [PATCH 2/3] gkeyfilesettingsbackend: Disallow empty key or group |
| 5 | names |
| 6 | |
| 7 | These should never have been allowed; they will result in precondition |
| 8 | failures from the `GKeyFile` later on in the code. |
| 9 | |
| 10 | A test will be added for this shortly. |
| 11 | |
| 12 | Signed-off-by: Philip Withnall <pwithnall@endlessos.org> |
| 13 | --- |
| 14 | gio/gkeyfilesettingsbackend.c | 7 +++++++ |
| 15 | 1 file changed, 7 insertions(+) |
| 16 | |
| 17 | diff --git a/gio/gkeyfilesettingsbackend.c b/gio/gkeyfilesettingsbackend.c |
| 18 | index 861c3a661..de216e615 100644 |
| 19 | --- a/gio/gkeyfilesettingsbackend.c |
| 20 | +++ b/gio/gkeyfilesettingsbackend.c |
| 21 | @@ -158,6 +158,13 @@ convert_path (GKeyfileSettingsBackend *kfsb, |
| 22 | |
| 23 | last_slash = strrchr (key, '/'); |
| 24 | |
| 25 | + /* Disallow empty group names or key names */ |
| 26 | + if (key_len == 0 || |
| 27 | + (last_slash != NULL && |
| 28 | + (*(last_slash + 1) == '\0' || |
| 29 | + last_slash == key))) |
| 30 | + return FALSE; |
| 31 | + |
| 32 | if (kfsb->root_group) |
| 33 | { |
| 34 | /* if a root_group was specified, make sure the user hasn't given |
| 35 | -- |
| 36 | 2.30.1 |
| 37 | |