Text that grows during parsing can overflow Parse_text
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
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
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_textpasses each line throughmaybe_convert_foreign_characters, which writes everyß(0xDF) as the two lettersss. That copy intoParse_texthas 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_textand 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
- 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 1 giorno 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
-
v9.6.0: CMake incorrectly enforces presence of libevdevForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
mltframework/shotcut#1943 ·
I maintainer di solito rispondono entro 1 giorno
-
Rowan (2017) electron heating gives NaN for beta > beta_max; clip() then sets electrons to kel_minAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
parthenon-hpc-lab/kharma#213 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
metasequoiaime/msime#9113 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
tone-3000/tone3000-plugin#257 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno