diff options
author | Matthias Clasen <matthiasc@src.gnome.org> | 2007-05-30 05:56:32 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2007-05-30 05:56:32 +0000 |
commit | 8bd39297a6c2887a87a8ee5ce967b07c6ccd2926 (patch) | |
tree | 90e17ca73c8ada67ee8824301a27389e7f5b4920 /gtk/gtkiconcachevalidator.c | |
parent | 07749fa1a338770f666d8edcd5b2d8c29c84c8d3 (diff) | |
download | gtk+-8bd39297a6c2887a87a8ee5ce967b07c6ccd2926.tar.gz |
Correct the handling of display names.
svn path=/trunk/; revision=17982
Diffstat (limited to 'gtk/gtkiconcachevalidator.c')
-rw-r--r-- | gtk/gtkiconcachevalidator.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/gtk/gtkiconcachevalidator.c b/gtk/gtkiconcachevalidator.c index 21c4ec2059..73cf351118 100644 --- a/gtk/gtkiconcachevalidator.c +++ b/gtk/gtkiconcachevalidator.c @@ -104,6 +104,32 @@ check_string (CacheInfo *info, } static gboolean +check_string_utf8 (CacheInfo *info, + guint32 offset) +{ + check ("string offset", offset < info->cache_size); + + if (info->flags & CHECK_STRINGS) + { + gint i; + gchar c; + + /* assume no string is longer than 1k */ + for (i = 0; i < 1024; i++) + { + check ("string offset", offset + i < info->cache_size) + c = *(info->cache + offset + i); + if (c == '\0') + break; + } + check ("string length", i < 1024); + check ("string utf8 data", g_utf8_validate((char *)(info->cache + offset), -1, NULL)); + } + + return TRUE; +} + +static gboolean check_directory_list (CacheInfo *info, guint32 offset) { @@ -172,16 +198,18 @@ static gboolean check_display_name_list (CacheInfo *info, guint32 offset) { - guint32 n_display_names; + guint32 n_display_names, ofs; gint i; check ("offset, display name list", get_uint32 (info, offset, &n_display_names)); for (i = 0; i < n_display_names; i++) { - if (!check_string (info, offset + 4 + 8 * i)) + get_uint32(info, offset + 4 + 8 * i, &ofs); + if (!check_string (info, ofs)) return FALSE; - if (!check_string (info, offset + 4 + 8 * i + 4)) + get_uint32(info, offset + 4 + 8 * i + 4, &ofs); + if (!check_string_utf8 (info, ofs)) return FALSE; } |