build-init/finish: Validate extension names

Otherwise, it becomes easy to accidentally create extensions with
invalid names. Ref #3887.
This commit is contained in:
Ryan Gonzalez
2020-10-05 11:18:03 -05:00
committed by Alexander Larsson
parent 9959fd80e9
commit 719eeee461
2 changed files with 9 additions and 0 deletions

View File

@@ -588,6 +588,12 @@ update_metadata (GFile *base, FlatpakContext *arg_context, gboolean is_runtime,
goto out;
}
if (!flatpak_is_valid_name (elements[0], error))
{
glnx_prefix_error (error, _("Invalid extension name %s"), elements[0]);
goto out;
}
groupname = g_strconcat (FLATPAK_METADATA_GROUP_PREFIX_EXTENSION,
elements[0], NULL);

View File

@@ -449,6 +449,9 @@ flatpak_builtin_build_init (int argc, char **argv, GCancellable *cancellable, GE
if (g_strv_length (elements) < 2)
return flatpak_fail (error, _("Too few elements in --extension argument %s, format should be NAME=VAR[=VALUE]"), opt_extensions[i]);
if (!flatpak_is_valid_name (elements[0], error))
return glnx_prefix_error (error, _("Invalid extension name %s"), elements[0]);
groupname = g_strconcat (FLATPAK_METADATA_GROUP_PREFIX_EXTENSION,
elements[0], NULL);