Skip to content

Commit d9923a1

Browse files
spikehkuba-moo
authored andcommitted
lib/ynl: reject strings with 0 len in ynl_attr_validate()
Strings from kernel are always null terminated which is checked for but it currently assumes that the len is > 0. Check that this is true before trying to access the char at (len - 1). Signed-off-by: David Wei <[email protected]>
1 parent 19f1235 commit d9923a1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/ynl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ int ynl_attr_validate(struct ynl_parse_arg* yarg, const struct nlattr* attr) {
426426
policy->name);
427427
return -1;
428428
case YNL_PT_NUL_STR:
429-
if ((!policy->len || len <= policy->len) && !data[len - 1])
429+
if (len && (!policy->len || len <= policy->len) && !data[len - 1])
430430
break;
431431
yerr(
432432
yarg->ys,

0 commit comments

Comments
 (0)