diff options
author | Philip Withnall <pwithnall@endlessos.org> | 2021-02-10 21:19:30 +0000 |
---|---|---|
committer | Philip Withnall <pwithnall@endlessos.org> | 2021-02-10 21:20:11 +0000 |
commit | a59247608feee2adcefafbbb774ed5f7d5275219 (patch) | |
tree | 61505982f9597be9af11a8982d93f4b19f46f30b | |
parent | 9d27c57f7035a6bb977070abadacfa479a0237d9 (diff) | |
download | glib-a59247608feee2adcefafbbb774ed5f7d5275219.tar.gz |
gkeyfilesettingsbackend: Disallow empty key or group names
These should never have been allowed; they will result in precondition
failures from the `GKeyFile` later on in the code.
A test will be added for this shortly.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
-rw-r--r-- | gio/gkeyfilesettingsbackend.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gio/gkeyfilesettingsbackend.c b/gio/gkeyfilesettingsbackend.c index d57a9d421..485a25a14 100644 --- a/gio/gkeyfilesettingsbackend.c +++ b/gio/gkeyfilesettingsbackend.c @@ -161,6 +161,13 @@ convert_path (GKeyfileSettingsBackend *kfsb, last_slash = strrchr (key, '/'); + /* Disallow empty group names or key names */ + if (key_len == 0 || + (last_slash != NULL && + (*(last_slash + 1) == '\0' || + last_slash == key))) + return FALSE; + if (kfsb->root_group) { /* if a root_group was specified, make sure the user hasn't given |