Skip to content

Commit 57e7ded

Browse files
committed
tools: ynl-gen: make sure we validate subtype of array-nest
ArrayNest AKA indexed-array support currently skips inner type validation. We count the attributes and then we parse them, make sure we call validate, too. Otherwise buggy / unexpected kernel response may lead to crashes. Fixes: be5bea1 ("net: add basic C code generators for Netlink") Reviewed-by: Donald Hunter <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ce6cb81 commit 57e7ded

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tools/net/ynl/pyynl/ynl_gen_c.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,11 @@ def _attr_typol(self):
714714
def _attr_get(self, ri, var):
715715
local_vars = ['const struct nlattr *attr2;']
716716
get_lines = [f'attr_{self.c_name} = attr;',
717-
'ynl_attr_for_each_nested(attr2, attr)',
718-
f'\t{var}->n_{self.c_name}++;']
717+
'ynl_attr_for_each_nested(attr2, attr) {',
718+
'\tif (ynl_attr_validate(yarg, attr2))',
719+
'\t\treturn YNL_PARSE_CB_ERROR;',
720+
f'\t{var}->n_{self.c_name}++;',
721+
'}']
719722
return get_lines, None, local_vars
720723

721724

0 commit comments

Comments
 (0)