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

LibPDF: Ensure that xref subsection numbers are u32

Previously, parsing an xref entry with a floating point subsection
number would cause a crash.
This commit is contained in:
Tim Ledbetter 2024-01-17 21:36:58 +00:00 committed by Jelle Raaijmakers
parent d2f3288666
commit 459fa8b840

View file

@ -499,9 +499,12 @@ PDFErrorOr<NonnullRefPtr<XRefTable>> DocumentParser::parse_xref_table()
Vector<XRefEntry> entries; Vector<XRefEntry> entries;
auto starting_index_value = TRY(parse_number()); auto starting_index_value = TRY(parse_number());
auto starting_index = starting_index_value.get<int>();
auto object_count_value = TRY(parse_number()); auto object_count_value = TRY(parse_number());
if (!(starting_index_value.has_u32() && object_count_value.has_u32()))
return error("Malformed xref entry");
auto object_count = object_count_value.get<int>(); auto object_count = object_count_value.get<int>();
auto starting_index = starting_index_value.get<int>();
for (int i = 0; i < object_count; i++) { for (int i = 0; i < object_count; i++) {
auto offset_string = ByteString(m_reader.bytes().slice(m_reader.offset(), 10)); auto offset_string = ByteString(m_reader.bytes().slice(m_reader.offset(), 10));