mirror of
https://github.com/openharmony/third_party_iptables.git
synced 2026-07-21 06:15:26 -04:00
libxt_string: Avoid potential array out of bounds access
The pattern index variable 'sindex' is bounds checked before incrementing it, which means in the next loop iteration it might already match the bounds check condition but is used anyway. Fix this by incrementing the index before performing the bounds check. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Florian Westphal <fw@strlen.de>
This commit is contained in:
committed by
Florian Westphal
parent
bfd41c8d99
commit
56d7ab42f3
@@ -159,9 +159,8 @@ parse_hex_string(const char *s, struct xt_string_info *info)
|
||||
info->pattern[sindex] = s[i];
|
||||
i++;
|
||||
}
|
||||
if (sindex > XT_STRING_MAX_PATTERN_SIZE)
|
||||
if (++sindex > XT_STRING_MAX_PATTERN_SIZE)
|
||||
xtables_error(PARAMETER_PROBLEM, "STRING too long \"%s\"", s);
|
||||
sindex++;
|
||||
}
|
||||
info->patlen = sindex;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user