LibGfx/WOFF: Return error if numTables is 0

This is consistent with WOFF2.
This commit is contained in:
Tim Ledbetter 2023-10-25 21:48:29 +01:00 committed by Andreas Kling
parent 52f78d07b8
commit 6e4c97a328
Notes: sideshowbarker 2024-07-18 04:38:32 +09:00

View file

@ -94,7 +94,7 @@ ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_externally_owned_memory(Readonl
auto expected_total_sfnt_size = sizeof(OpenType::TableDirectory) + header.num_tables * 16;
if (header.length > buffer.size())
return Error::from_string_literal("Invalid WOFF length");
if (header.num_tables > NumericLimits<u16>::max() / 16)
if (header.num_tables == 0 || header.num_tables > NumericLimits<u16>::max() / 16)
return Error::from_string_literal("Invalid WOFF numTables");
if (header.reserved != 0)
return Error::from_string_literal("Invalid WOFF reserved field");