Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Loading a .eff file longer than 1023 bytes overflows a stack buffer

Aperta
#7,869 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
game-dev

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

bug sanitizer/stability

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

  1. In a mod's data/maps, add a two-frame animation: longeff_0000.png, longeff_0001.png, and longeff.eff containing $Type: png and $Frames: 2, followed by comment lines until the file is over 1024 bytes (mine was 4,231 bytes).
  2. 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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di scp-fs2open/fs2open.github.com

Tutte le issue di scp-fs2open/fs2open.github.com

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.