From: Peter Krempa <pkrempa@redhat.com> If the actual type of the typed parameter is an invalid number the type checker would still attempt to convert it to a string resuling in an attempt to print a NULL string. libc saves us from the crash but the error message is still wrong. Fix it. Fixes: 54dd75fd97339dd49a54554e9327e5680c72132b Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virtypedparam.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 0b40c14f90..6cfdd3276d 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -56,6 +56,13 @@ int virTypedParamValidateType(virTypedParameterPtr param, unsigned int expected_type) { + if (param->type <= 0 || param->type >= VIR_TYPED_PARAM_LAST) { + virReportError(VIR_ERR_INVALID_ARG, + _("unknown type ('%1$d') of parameter '%2$s'"), + param->type, param->field); + return -1; + } + if (param->type != expected_type) { virReportError(VIR_ERR_INVALID_ARG, _("invalid type '%1$s' for parameter '%2$s', expected '%3$s'"), -- 2.54.0