LibPDF: Don't overflow SIDs in type 1 charset parsing

first_sid has type SID (aka u16), so don't store it in an u8.

This fixes (among other things) page 24 on the PDF 1.7 spec.
This commit is contained in:
Nico Weber 2023-10-13 10:32:57 -04:00 committed by Jelle Raaijmakers
parent 403d3bbdaf
commit 49275c4b17
Notes: sideshowbarker 2024-07-17 23:07:41 +09:00

View file

@ -631,7 +631,7 @@ PDFErrorOr<Vector<DeprecatedFlyString>> CFF::parse_charset(Reader&& reader, size
while (names.size() < glyph_count - 1) {
auto first_sid = TRY(reader.try_read<BigEndian<SID>>());
int left = TRY(reader.try_read<Card8>());
for (u8 sid = first_sid; left >= 0; left--, sid++)
for (SID sid = first_sid; left >= 0; left--, sid++)
TRY(names.try_append(resolve_sid(sid, strings)));
}
}