summaryrefslogtreecommitdiff
path: root/metadata
diff options
context:
space:
mode:
authorChristian Kellner <gicmo@gnome.org>2009-11-18 14:40:38 +0100
committerChristian Kellner <gicmo@gnome.org>2009-11-18 15:07:13 +0100
commit5e0cd74ada6749ab7e489db2fa22bd8cb5d2881c (patch)
tree084bd9732915eefef0de18405d7e4cddf32071be /metadata
parent9c675118616667c21d99a5b982229da935ea7ff4 (diff)
downloadgvfs-5e0cd74ada6749ab7e489db2fa22bd8cb5d2881c.tar.gz
Reread metadata only when the inodes are different
This will protect against bugs where the stable file has the rotated bug set (which should never happen but see bug #600057)
Diffstat (limited to 'metadata')
-rw-r--r--metadata/metatree.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/metadata/metatree.c b/metadata/metatree.c
index 36abb9b3..4a0e5f5d 100644
--- a/metadata/metatree.c
+++ b/metadata/metatree.c
@@ -158,6 +158,7 @@ struct _MetaTree {
int fd;
char *data;
gsize len;
+ ino_t inode;
guint32 tag;
gint64 time_t_base;
@@ -469,6 +470,7 @@ meta_tree_init (MetaTree *tree)
tree->fd = fd;
tree->len = statbuf.st_size;
+ tree->inode = statbuf.st_ino;
tree->data = data;
tree->header = (MetaFileHeader *)data;
@@ -614,12 +616,24 @@ meta_tree_unref (MetaTree *tree)
static gboolean
meta_tree_needs_rereading (MetaTree *tree)
{
+ struct stat statbuf;
+
if (tree->fd == -1)
return TRUE;
if (tree->header != NULL &&
GUINT32_FROM_BE (tree->header->rotated) == 0)
return FALSE; /* Got a valid tree and its not rotated */
+
+ /* Sanity check to avoid infinite loops when a stable file
+ has the rotated bit set to 1 (see gnome bugzilla bug #600057) */
+
+ if (lstat (tree->filename, &statbuf) != 0)
+ return FALSE;
+
+ if (tree->inode == statbuf.st_ino)
+ return FALSE;
+
return TRUE;
}