[ostree] commit: Store detached metadata in normal form



commit b0645815770e0721d8915f924903d3a0a51e3964
Author: Colin Walters <walters verbum org>
Date:   Sun Sep 29 14:00:53 2013 -0400

    commit: Store detached metadata in normal form
    
    Otherwise corrupted variants may crash us.

 src/libostree/ostree-repo-commit.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c
index fe44956..02f27e2 100644
--- a/src/libostree/ostree-repo-commit.c
+++ b/src/libostree/ostree-repo-commit.c
@@ -1329,14 +1329,17 @@ ostree_repo_write_commit_detached_metadata (OstreeRepo      *self,
   gboolean ret = FALSE;
   gs_unref_object GFile *metadata_path =
     _ostree_repo_get_commit_metadata_loose_path (self, checksum);
+  gs_unref_variant GVariant *normalized = NULL;
 
   if (!_ostree_repo_ensure_loose_objdir_at (self->objects_dir_fd, checksum,
                                             cancellable, error))
     goto out;
 
+  normalized = g_variant_get_normal_form (metadata);
+
   if (!g_file_replace_contents (metadata_path,
-                                g_variant_get_data (metadata),
-                                g_variant_get_size (metadata),
+                                g_variant_get_data (normalized),
+                                g_variant_get_size (normalized),
                                 NULL, FALSE, 0, NULL,
                                 cancellable, error))
     goto out;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]