From 1904e3e0f4472d98258bbe27887bf87d269705d8 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 14 Aug 2013 10:10:08 +0200 Subject: [PATCH] Don't pass non-checksums to ostree_repo_has_object() The 'ostree show' command passed non-checksum arguments to the ostree_repo_has_object() function which led to an assertion. https://bugzilla.gnome.org/show_bug.cgi?id=705967 --- src/ostree/ot-builtin-show.c | 10 +++++----- tests/test-basic.sh | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ostree/ot-builtin-show.c b/src/ostree/ot-builtin-show.c index 82a8e019..206999ad 100644 --- a/src/ostree/ot-builtin-show.c +++ b/src/ostree/ot-builtin-show.c @@ -143,7 +143,7 @@ do_print_metadata_key (OstreeRepo *repo, static gboolean print_if_found (OstreeRepo *repo, OstreeObjectType objtype, - const char *rev, + const char *checksum, gboolean *inout_was_found, GCancellable *cancellable, GError **error) @@ -154,17 +154,17 @@ print_if_found (OstreeRepo *repo, if (*inout_was_found) return TRUE; - if (!ostree_repo_has_object (repo, objtype, rev, &have_object, + if (!ostree_repo_has_object (repo, objtype, checksum, &have_object, cancellable, error)) goto out; if (have_object) { gs_unref_variant GVariant *variant = NULL; - if (!ostree_repo_load_variant (repo, objtype, rev, + if (!ostree_repo_load_variant (repo, objtype, checksum, &variant, error)) goto out; *inout_was_found = TRUE; - g_print ("Object: %s\nType: %s\n", rev, ostree_object_type_to_string (objtype)); + g_print ("Object: %s\nType: %s\n", checksum, ostree_object_type_to_string (objtype)); print_variant (variant); } @@ -223,7 +223,7 @@ ostree_builtin_show (int argc, char **argv, GFile *repo_path, GCancellable *canc else { gboolean found = FALSE; - if (!ostree_validate_rev (rev, NULL)) + if (!ostree_validate_checksum_string (rev, NULL)) { gs_unref_variant GVariant *variant = NULL; if (!ostree_repo_resolve_rev (repo, rev, FALSE, &resolved_rev, error)) diff --git a/tests/test-basic.sh b/tests/test-basic.sh index c6401ad5..baef00c9 100755 --- a/tests/test-basic.sh +++ b/tests/test-basic.sh @@ -19,7 +19,7 @@ set -e -echo "1..35" +echo "1..36" . $(dirname $0)/libtest.sh @@ -245,3 +245,6 @@ cd ${test_tmpdir} $OSTREE ls test2 echo "ok ls with no argument" +cd ${test_tmpdir} +$OSTREE show test2 +echo "ok show with non-checksum"