repo/commit: Don't renormalize trusted metadata

As the comment in the code says; in the expected checksum case, the caller
really has to have a normal form already.

Closes: #881
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2017-06-01 18:43:38 +00:00
1 parent 6ba4dac6f2
commit ec1964dd44
1 file changed
+10 -1
+10 -1
View File
@@ -1511,6 +1511,7 @@ ostree_repo_write_metadata (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GVariant) normalized = NULL;
/* First, if we have an expected checksum, see if we already have this
* object. This mirrors the same logic in ostree_repo_write_content().
*/
@@ -1526,9 +1527,17 @@ ostree_repo_write_metadata (OstreeRepo *self,
*out_csum = ostree_checksum_to_bytes (expected_checksum);
return TRUE;
}
/* If the caller is giving us an expected checksum, the object really has
* to be normalized already. Otherwise, how would they know the checksum?
* There's no sense in redoing it.
*/
normalized = g_variant_ref (object);
}
else
{
normalized = g_variant_get_normal_form (object);
}
g_autoptr(GVariant) normalized = g_variant_get_normal_form (object);
if (!metadata_size_valid (objtype, g_variant_get_size (normalized), error))
return FALSE;