varlink: allow strings for integer varlink IDL fields
This is a follow-up for 67a3028555: also
allow strings as integer during IDL validation of JSON records.
This commit is contained in:
committed by
Luca Boccassi
parent
a7839bff68
commit
217f63c9b8
@@ -1379,7 +1379,8 @@ static int varlink_idl_validate_field_element_type(const VarlinkField *field, Js
|
||||
break;
|
||||
|
||||
case VARLINK_INT:
|
||||
if (!json_variant_is_integer(v) && !json_variant_is_unsigned(v))
|
||||
/* Allow strings here too, since integers with > 53 bits are often passed in as strings */
|
||||
if (!json_variant_is_integer(v) && !json_variant_is_unsigned(v) && !json_variant_is_string(v))
|
||||
return varlink_idl_log(SYNTHETIC_ERRNO(EMEDIUMTYPE), "Field '%s' should be an int, but it is not, refusing.", strna(field->name));
|
||||
|
||||
break;
|
||||
|
||||
@@ -385,7 +385,7 @@ TEST(validate_method_call) {
|
||||
|
||||
assert_se(varlink_callb(v, "xyz.TestMethod", &reply, &error_id,
|
||||
JSON_BUILD_OBJECT(
|
||||
JSON_BUILD_PAIR_STRING("foo", "wuff"),
|
||||
JSON_BUILD_PAIR_BOOLEAN("foo", true),
|
||||
JSON_BUILD_PAIR_UNSIGNED("bar", 9))) >= 0);
|
||||
assert_se(streq_ptr(error_id, VARLINK_ERROR_INVALID_PARAMETER));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user