LibWeb: Restrict HTMLInputElement::max_length to the range of i32

This commit is contained in:
Tim Ledbetter 2024-11-30 20:00:53 +00:00 committed by Andreas Kling
parent 163ec18593
commit 40d6b9d44e
Notes: github-actions[bot] 2024-12-02 09:27:09 +00:00
3 changed files with 20 additions and 1 deletions

View file

@ -1832,7 +1832,7 @@ WebIDL::Long HTMLInputElement::max_length() const
{
// The maxLength IDL attribute must reflect the maxlength content attribute, limited to only non-negative numbers.
if (auto maxlength_string = get_attribute(HTML::AttributeNames::maxlength); maxlength_string.has_value()) {
if (auto maxlength = parse_non_negative_integer(*maxlength_string); maxlength.has_value())
if (auto maxlength = parse_non_negative_integer(*maxlength_string); maxlength.has_value() && *maxlength <= 2147483647)
return *maxlength;
}
return -1;