Loading a .eff file longer than 1023 bytes overflows a stack buffer
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 62/100
Direzione di ricerca
Start in code/bmpman/bmpman.cpp at bm_load_and_parse_eff, where the two fixed 1024-byte stack buffers are declared, then follow the calls into read_file_text and read_raw_file_text. Read process_raw_file_text too, since the ß to ss expansion can make the text longer than the file. Reproduce with a .eff over 1024 bytes. Done means that file either loads or is rejected with a warning, with no stack smashing, and that the expansion cases are covered.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
bm_load_and_parse_eff (code/bmpman/bmpman.cpp) reads the whole .eff file into two fixed 1024-byte arrays on the stack, file_text and file_text_raw. Nothing checks the file's length first, so a longer .eff writes past them. A release build aborts with "stack smashing detected".
Reproduction
- In a mod's
data/maps, add a two-frame animation:longeff_0000.png,longeff_0001.png, andlongeff.effcontaining$Type: pngand$Frames: 2, followed by comment lines until the file is over 1024 bytes (mine was 4,231 bytes). - Load it, for example from Lua:
gr.loadTexture("longeff", true).
On nightly 26.1.0-20261013 (release build, Linux) the game aborts with *** stack smashing detected ***: terminated. The same animation with a 601-byte .eff loads normally in the same session.
Expected vs actual
Expected: the animation loads, or a file that is too long is skipped with a warning.
Actual: the game aborts.
Mechanism
read_file_text is handed the caller's buffers, and read_raw_file_text reads the whole file into them without knowing their size. Comments make an .eff longer than its four keys suggest. The text can also come out longer than the file: older 7-bit encrypted files unpack 7 bytes into 8 characters, and in the default text mode process_raw_file_text writes each ß as ss.
Fix alternatives
- Check the file length before reading, leaving room for the growth above, and warn when it's too long.
- Or allocate the buffers from the file length instead of using fixed arrays.
- Lingua principale
- C++
- Stelle
- 488
- Fork
- 184
- Merge medio
- 2g 9h
- PR unite (30g)
- 39
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. 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 scp-fs2open/fs2open.github.com
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
scp-fs2open/fs2open.github.com#7918 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
scp-fs2open/fs2open.github.com#7917 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
scp-fs2open/fs2open.github.com#7916 ·
I maintainer di solito rispondono entro 1 giorno
-
P2: A timed rotation maneuver does nothing on a ship that had an earlier timed lateral maneuverForse già presa @vovosta l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
scp-fs2open/fs2open.github.com#7914 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
scp-fs2open/fs2open.github.com#7901 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di scp-fs2open/fs2open.github.com
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
OpenSpace/OpenSpace#4353 · 1 commento ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
justcallmekoko/ESP32Marauder#1656 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
macOS: a double-click on a notarized altairsim is refused, and the docs give only the offline caseForse già presa @anhaoXie l’ha presa oggi. Apertadocumentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
mutationpp/Mutationpp#337 ·