1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:07:34 +00:00

LibCrypto: Don't crash in ASN1::parse_generalized_time on missing 'Z'

This commit is contained in:
Ben Wiederhake 2022-09-11 22:55:33 +02:00 committed by Andreas Kling
parent 0ca41d2813
commit 0aed7f1c8e
2 changed files with 110 additions and 5 deletions

View file

@ -140,7 +140,7 @@ Optional<Core::DateTime> parse_generalized_time(StringView time)
if (!minute.has_value()) {
return {};
}
if (lexer.consume_specific('Z'))
if (lexer.is_eof() || lexer.consume_specific('Z'))
goto done_parsing;
}
@ -149,7 +149,7 @@ Optional<Core::DateTime> parse_generalized_time(StringView time)
if (!seconds.has_value()) {
return {};
}
if (lexer.consume_specific('Z'))
if (lexer.is_eof() || lexer.consume_specific('Z'))
goto done_parsing;
}
@ -158,7 +158,7 @@ Optional<Core::DateTime> parse_generalized_time(StringView time)
if (!milliseconds.has_value()) {
return {};
}
if (lexer.consume_specific('Z'))
if (lexer.is_eof() || lexer.consume_specific('Z'))
goto done_parsing;
}
@ -169,8 +169,11 @@ Optional<Core::DateTime> parse_generalized_time(StringView time)
if (!offset_hours.has_value() || !offset_minutes.has_value()) {
return {};
}
} else {
lexer.consume();
}
// Any character would be garbage.
if (!lexer.is_eof()) {
return {};
}
}