Fix gen3 HoF clamp, reject invalid sector IDs

Closes #4229
This commit is contained in:
Kurt 2024-03-21 08:55:48 -05:00
parent 205e9b433d
commit c1b98025f7
2 changed files with 4 additions and 2 deletions

View file

@ -106,6 +106,8 @@ public abstract class SAV3 : SaveFile, ILangDeviantSave, IEventFlag37, IBoxDetai
{ {
var span = data[ofs..]; var span = data[ofs..];
var id = ReadInt16LittleEndian(span[0xFF4..]); var id = ReadInt16LittleEndian(span[0xFF4..]);
if ((uint)id >= COUNT_MAIN)
return false; // invalid sector ID
bitTrack |= (1 << id); bitTrack |= (1 << id);
if (id == 0) if (id == 0)
sector0 = ofs; sector0 = ofs;

View file

@ -504,7 +504,7 @@ public partial class SAV_Misc3 : Form
public void SetFameTime(uint time) public void SetFameTime(uint time)
{ {
NUD_FameH.Value = Math.Min(NUD_FameH.Maximum, time >> 16); NUD_FameH.Value = Math.Min(NUD_FameH.Maximum, time >> 16);
NUD_FameM.Value = Math.Min(NUD_FameH.Maximum, (byte)(time >> 8)); NUD_FameM.Value = Math.Min(NUD_FameM.Maximum, (byte)(time >> 8));
NUD_FameS.Value = Math.Min(NUD_FameH.Maximum, (byte)time); NUD_FameS.Value = Math.Min(NUD_FameS.Maximum, (byte)time);
} }
} }