The object_new_with_props/propv methods failed to validate the ID string format, thus diverging from user_creatable_add_type.
Tested-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]> Signed-off-by: Daniel P. Berrangé <[email protected]> --- qom/object.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qom/object.c b/qom/object.c index 4a15151c3b..08fc840f39 100644 --- a/qom/object.c +++ b/qom/object.c @@ -24,6 +24,8 @@ #include "qapi/forward-visitor.h" #include "qapi/qapi-builtin-visit.h" #include "qobject/qjson.h" +#include "qemu/id.h" +#include "qapi/qmp/qerror.h" #include "trace.h" /* TODO: replace QObject with a simpler visitor to avoid a dependency @@ -755,6 +757,13 @@ Object *object_new_with_propv(const char *typename, ObjectClass *klass; UserCreatable *uc; + if (id != NULL && !id_wellformed(id)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id", "an identifier"); + error_append_hint(errp, "Identifiers consist of letters, digits, " + "'-', '.', '_', starting with a letter.\n"); + return NULL; + } + klass = object_class_by_name(typename); if (!klass) { error_setg(errp, "invalid object type: %s", typename); -- 2.54.0
