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

Text that grows during parsing can overflow Parse_text

Aperta
#7,870 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
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
data

Direzione di ricerca

Start in code/parse/parselo.cpp with read_raw_file_text, where allocate_parse_text(file_len + 1) sizes Parse_text and Parse_text_raw, then follow process_raw_file_text and maybe_convert_foreign_characters to see where the ß-to-ss expansion and 7-bit decryption write. Pick one fix: size both buffers for the worst case, or bound the copy and grow the buffer. Done when a file full of 0xDF bytes and a 7-bit encrypted file both fit their buffers without overflow.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug sanitizer/stability

Problem

read_raw_file_text sizes Parse_text and Parse_text_raw from the file's length (allocate_parse_text(file_len + 1) in code/parse/parselo.cpp), but the text written into them can be longer than the file:

  • In the default (non-Unicode) text mode, process_raw_file_text passes each line through maybe_convert_foreign_characters, which writes every ß (0xDF) as the two letters ss. That copy into Parse_text has no size check.
  • A file using the older 7-bit encryption is decrypted into Parse_text_raw, and that format unpacks every 7 stored bytes into 8 characters.

So a table made mostly of ß characters, or an old-style encrypted table, can write past the end of the heap buffer when it is the largest file parsed so far.

Reproduction

Found by reading the code while reviewing a new text reader for #7865; I haven't triggered it in game, since the buffers only grow and a larger file read earlier hides it. Running the same line-splitting, comment-stripping and maybe_convert_foreign_characters code over a 1 MB file of 0xDF bytes (a newline every 100 bytes) wrote 2,086,667 bytes, about twice the allocation allocate_parse_text would make for that file.

Expected vs actual

Expected: the converted text fits its buffer.
Actual: the conversion can write past the end of Parse_text, and decryption past Parse_text_raw.

Fix alternatives

  • Size both buffers for the worst case: twice the raw text in non-Unicode mode, 8/7 of the file for 7-bit encrypted files.
  • Or bound the copy in process_raw_file_text and grow the buffer when it would overflow.

The .eff reader has the same problem with fixed stack buffers: #7869.

Lingua principale
C++
Stelle
488
Fork
184
Merge medio
2g 9h
PR unite (30g)
40

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.