summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kellner <gicmo@gnome.org>2009-11-18 14:40:38 +0100
committerAlexander Larsson <alexl@redhat.com>2009-11-27 15:14:35 +0100
commit6e397fbf15e074ba598de33240596f6b31211dc5 (patch)
tree4bb17b878f5cd29701610340af5a4056f8d9a048
parent64f936f3ad40ca52e115099b62b3b4912323a800 (diff)
downloadgvfs-6e397fbf15e074ba598de33240596f6b31211dc5.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) (cherry picked from commit 5e0cd74ada6749ab7e489db2fa22bd8cb5d2881c)
-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;
}