If the actual type of the typed parameter is an invalid number the type
checker would still attempt to convert it to a string resulting 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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
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'"),