mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Correctly handle some short save files
A save file that ended in the middle of a value before the "SAVEFILE" field had been loaded would cause a read from uninitialised memory. While technically undefined behaviour this was practically pretty harmless. Fixed by handling unexpected EOF here the same an unexpected EOF anywhere else. This bug could be demonstrated by loading a truncated save file like this in a build with MemorySanitizer enabled: SAVEFILE:41:Simo
This commit is contained in:
4
midend.c
4
midend.c
@ -2340,7 +2340,7 @@ static const char *midend_deserialise_internal(
|
|||||||
|
|
||||||
val = snewn(len+1, char);
|
val = snewn(len+1, char);
|
||||||
if (!read(rctx, val, len)) {
|
if (!read(rctx, val, len)) {
|
||||||
if (started)
|
/* unexpected EOF */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
val[len] = '\0';
|
val[len] = '\0';
|
||||||
@ -2747,7 +2747,7 @@ const char *identify_game(char **name,
|
|||||||
|
|
||||||
val = snewn(len+1, char);
|
val = snewn(len+1, char);
|
||||||
if (!read(rctx, val, len)) {
|
if (!read(rctx, val, len)) {
|
||||||
if (started)
|
/* unexpected EOF */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
val[len] = '\0';
|
val[len] = '\0';
|
||||||
|
Reference in New Issue
Block a user