summaryrefslogtreecommitdiff
path: root/gio/gresource.c
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2018-07-05 12:01:48 +0100
committerPhilip Withnall <withnall@endlessm.com>2018-07-05 12:03:10 +0100
commitab87af17340ff56a2000f0704c15f2dc4c98ed72 (patch)
tree690a4201fc99781a5424dadfdb78971ce8d8a095 /gio/gresource.c
parentf62d7c1e2a38006a6ad1d735135f222ce5ceb726 (diff)
downloadglib-ab87af17340ff56a2000f0704c15f2dc4c98ed72.tar.gz
gresource: Fix potential array overflow if using empty paths
Adds tests to cover this case and similar cases for various GResource methods in future. Signed-off-by: Philip Withnall <withnall@endlessm.com> https://gitlab.gnome.org/GNOME/glib/issues/927
Diffstat (limited to 'gio/gresource.c')
-rw-r--r--gio/gresource.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/gio/gresource.c b/gio/gresource.c
index 18383d9b6..bf54f1d78 100644
--- a/gio/gresource.c
+++ b/gio/gresource.c
@@ -606,8 +606,9 @@ do_lookup (GResource *resource,
gboolean res = FALSE;
GVariant *value;
+ /* Drop any trailing slash. */
path_len = strlen (path);
- if (path[path_len-1] == '/')
+ if (path_len >= 1 && path[path_len-1] == '/')
{
path = free_path = g_strdup (path);
free_path[path_len-1] = 0;