mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-16 10:50:43 +03:00
core: Add API to validate rev
This commit is contained in:
parent
810a3dac86
commit
b783ebc189
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user