diff options
author | Ondrej Holy <oholy@redhat.com> | 2015-12-10 16:22:39 +0100 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2015-12-14 13:40:15 +0100 |
commit | f839c18b279bbcb079c6738e3781351f51107c23 (patch) | |
tree | c86591c9220d8f684dc91179c02da69e299fcee8 /metadata/metabuilder.c | |
parent | 08d89cc4818bb7efed104556643c6dc5ace84e63 (diff) | |
download | gvfs-f839c18b279bbcb079c6738e3781351f51107c23.tar.gz |
metadata: Avoid endless recursion when copying meta files
meta_builder_copy is traversing the tree while at the same time possibly
writing to it. This might leads to endless recursion and consequent
segmentation fault. Do the entire copy into a new MetaFile that is not
inserted into the source tree and consequently insert the MetaFile once
the copy is done.
https://bugzilla.gnome.org/show_bug.cgi?id=759341
Diffstat (limited to 'metadata/metabuilder.c')
-rw-r--r-- | metadata/metabuilder.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/metadata/metabuilder.c b/metadata/metabuilder.c index af9e99da..7c419b83 100644 --- a/metadata/metabuilder.c +++ b/metadata/metabuilder.c @@ -298,7 +298,7 @@ meta_builder_copy (MetaBuilder *builder, const char *dest_path, guint64 mtime) { - MetaFile *src, *dest; + MetaFile *src, *dest, *temp; meta_builder_remove (builder, dest_path, mtime); @@ -306,9 +306,15 @@ meta_builder_copy (MetaBuilder *builder, if (src == NULL) return; + temp = metafile_new (NULL, NULL); + meta_file_copy_into (src, temp, mtime); + dest = meta_builder_lookup (builder, dest_path, TRUE); + dest->data = temp->data; + dest->children = temp->children; + dest->last_changed = temp->last_changed; - meta_file_copy_into (src, dest, mtime); + g_free (temp); } void |