[ostree] core: Add API to validate rev
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] core: Add API to validate rev
- Date: Mon, 27 Feb 2012 13:39:15 +0000 (UTC)
commit b783ebc189b08643f30eac45da0d1db6f93c1513
Author: Colin Walters <walters verbum org>
Date: Mon Feb 27 08:37:37 2012 -0500
core: Add API to validate rev
src/libostree/ostree-core.c | 23 +++++++++++++++++++++++
src/libostree/ostree-core.h | 2 ++
src/libostree/ostree-repo.c | 13 ++-----------
3 files changed, 27 insertions(+), 11 deletions(-)
---
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index 929d834..3fe6d22 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -58,6 +58,29 @@ ostree_validate_checksum_string (const char *sha256,
return TRUE;
}
+gboolean
+ostree_validate_rev (const char *rev,
+ GError **error)
+{
+ gboolean ret = FALSE;
+ GPtrArray *components = NULL;
+
+ if (!ot_util_path_split_validate (rev, &components, error))
+ goto out;
+
+ if (components->len == 0)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Invalid empty rev");
+ goto out;
+ }
+
+ ret = TRUE;
+ out:
+ g_ptr_array_unref (components);
+ return ret;
+}
+
GVariant *
ostree_wrap_metadata_variant (OstreeObjectType type,
GVariant *metadata)
diff --git a/src/libostree/ostree-core.h b/src/libostree/ostree-core.h
index 0772ca9..24489ce 100644
--- a/src/libostree/ostree-core.h
+++ b/src/libostree/ostree-core.h
@@ -100,6 +100,8 @@ typedef enum {
gboolean ostree_validate_checksum_string (const char *sha256,
GError **error);
+gboolean ostree_validate_rev (const char *rev, GError **error);
+
void ostree_checksum_update_stat (GChecksum *checksum, guint32 uid, guint32 gid, guint32 mode);
const char * ostree_object_type_to_string (OstreeObjectType objtype);
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 0192b7a..dc0baef 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -339,20 +339,11 @@ ostree_repo_resolve_rev (OstreeRepo *self,
g_return_val_if_fail (rev != NULL, FALSE);
- /* This checks for .. and such, but we don't actually walk
- * the parsed bits below.
- */
- if (!ot_util_path_split_validate (rev, &components, error))
+ if (!ostree_validate_rev (rev, error))
goto out;
- if (components->len == 0)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid empty rev");
- goto out;
- }
/* We intentionally don't allow a ref that looks like a checksum */
- else if (ostree_validate_checksum_string (rev, NULL))
+ if (ostree_validate_checksum_string (rev, NULL))
{
ret_rev = g_strdup (rev);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]