Panic: u16 overflow in name.rs when a name record's offset + length exceeds 65535
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 75/100
Direzione di ricerca
Leggi src/name.rs, in particolare subset_table intorno alle due aggiunte individuate nell’issue. Esegui la riproduzione fornita o cargo test per osservare l’overflow, quindi verifica che gli offset non validi restituiscano un errore invece di causare un panic e che gli offset di stringa accumulati non vadano in overflow.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
subset panics with attempt to add with overflow when a name record's offset + length exceeds 65535, in any build with overflow checks (debug builds, cargo test, fuzzing):
thread 'main' panicked at subsetter-0.2.6/src/name.rs:48:20:
attempt to add with overflow
subset_table in src/name.rs adds record.string_offset + record.length as u16 (line 48), and cur_storage_offset += record.length (line 53) can overflow the same way when the kept strings add up to more than 64 KiB. In release builds the first sum wraps, storage.get(..) returns None and the call ends in Err(SubsetError); the second can wrap silently and write wrong string offsets.
To reproduce with subsetter 0.2.6 (default-features = false) and the font below (696 bytes, a minimal TrueType font whose name table has a single record: platform 3, encoding 1, language 0x409, name ID 1, length 4, offset 0xFFFE):
fn main() {
let data = std::fs::read("name-overflow.ttf").unwrap();
let remapper = subsetter::GlyphRemapper::new();
println!("{:?}", subsetter::subset(&data, 0, &remapper).map(|font| font.len()));
}
cargo run panics as above; cargo run --release prints Err(SubsetError).
name-overflow.ttf, base64 (decode with base64 -d > name-overflow.ttf)
AAEAAAAKAIAAAwAgT1MvMmKwXBUAAAEoAAAAYGNtYXABSgEcAAABnAAAAExnbHlmC4EjVwAAAgAA
AACAaGVhZMSNyOUAAACsAAAANmhoZWEF1AGWAAAA5AAAACRobXR4CMoAlgAAAYgAAAAUbG9jYQAA
AXAAAAHoAAAAGG1heHAACwANAAABCAAAACBuYW1lAFQEUgAAAoAAAAAWcG9zdP+fADIAAAKYAAAA
IAABAAAAAQAAIE34C18PPPUACwPoAAAAAHwlncAAAAAA5vHm7QAAAAACWANSAAAACAACAAEAAAAA
AAEAAAMg/zgAWgJYAAAAAAJYAAEAAAAAAAAAAAAAAAAAAAAFAAEAAAAFAAQAAQAGAAIAAgAAAAAA
AAAAAAAAAAACAAEABAHCAZAABQAAAooCWAAAAEsCigJYAAABXgAyAPoAAAAAAAAAAAAAAAAAAAAD
AAAAAAAAAAAAAAAAT1dSVABAACAAwQMg/zgAWgOEAPoAAAABAAAAAAH0ArwAAAAgAAAB9AAyAPoA
AAJYAAABLABkAlgAAAAAAAIAAAADAAAAFAADAAEAAAAUAAQAOAAAAAoACAACAAIAIABBALQAwf//
AAAAIABBALQAwf///+H/wf9P/0MAAQAAAAAAAAAAAAAAAAAAAAAAJAAAACQAAABEAAAAZAAAAIAA
AQAyAAABwgK8AAMAAAEBAQEAMgAAAZAAAAAAArwAAP1EAAAAAQAAAAACWAK8AAIAAAEBAQAAASwB
LAAAArz9RAAAAAABAGQCWAD6Au4AAgAAAQEBAGQAZAAyAlgAlv/OAAAA//8AAAAAAlgDUgAjAAIA
AAAAAAMAAwBkAGQAAAAAAAEAEgADAAEECQABAAT//gBBAEIAAAADAAAAAAAA/5wAMgAAAAAAAAAA
AAAAAAAAAAAAAAAA
Doing the arithmetic in usize or with checked_add, and returning MalformedFont when it does not fit, would make this an error. Found by fuzzing subsetter through the font crate of officewright; until it is fixed we call subset inside catch_unwind.
- Lingua principale
- Rust
- Stelle
- 61
- Fork
- 16
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di typst/subsetter
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
-
head table bounding box is not recalculated for variable font instancesForse già presa @khaledhosny l’ha presa 16 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 56/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
-
Difficoltà 3/5 Mezza giornata Idoneità per principianti 67/100
Tutte le issue di typst/subsetter
Issue simili
-
Input: placeholder drawn in the text colour when the empty Input is focused but not yet editedAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pierreaubert/gpui-toolkit#114 ·
I maintainer di solito rispondono entro 1 giorno
-
BibLaTeX `type` keys like `phdthesis`, `mathesis`, `techreport` are printed raw instead of localizedAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
remove the use of `forget`Apertagood first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
compiler
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
HerringtonDarkholme/hd-lang#1853 ·
I maintainer di solito rispondono entro 1 giorno
-
bug needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
pbakaus/impeccable#1462 ·
I maintainer di solito rispondono entro 1 giorno