summaryrefslogtreecommitdiff
path: root/gtk/gtkiconcache.c
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2011-10-03 23:25:33 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2011-10-03 23:25:33 +0800
commiteb8c2dfae297f340279e2a1c848b14584f0c1dc7 (patch)
treeaa20ac644e03935e3afaa516aeca039a33fcb68f /gtk/gtkiconcache.c
parent25e65dc1b59527badfef052f988639c1ef22f22d (diff)
downloadgtk+-eb8c2dfae297f340279e2a1c848b14584f0c1dc7.tar.gz
Bug 660730: Use GStatBuf for portability
Thanks to Kean Johnston for pointing this out. There are a few places in GTK that use "struct stat", and then g_stat(), rather than using GStatBuf.This breaks things on Windows. Since the size of struct stat can vary depending on other flags specified, this has the potential to cause overwrites and is trivial to fix. Based on patch submitted by Kean Johnston
Diffstat (limited to 'gtk/gtkiconcache.c')
-rw-r--r--gtk/gtkiconcache.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/gtk/gtkiconcache.c b/gtk/gtkiconcache.c
index ecaf6df1ea..855b270be4 100644
--- a/gtk/gtkiconcache.c
+++ b/gtk/gtkiconcache.c
@@ -89,8 +89,8 @@ _gtk_icon_cache_new_for_path (const gchar *path)
gchar *cache_filename;
gint fd = -1;
- struct stat st;
- struct stat path_st;
+ GStatBuf st;
+ GStatBuf path_st;
CacheInfo info;
/* Check if we have a cache file */
@@ -107,7 +107,12 @@ _gtk_icon_cache_new_for_path (const gchar *path)
if (fd < 0)
goto done;
-
+
+#ifdef G_OS_WIN32
+#undef fstat /* Just in case */
+#define fstat _fstat32
+#endif
+
if (fstat (fd, &st) < 0 || st.st_size < 4)
goto done;