Skip to content

Commit 9bffab7

Browse files
committed
port: do not read past the end of EEPROM when scanning for headers
1 parent a040b29 commit 9bffab7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/game/pak.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,11 @@ PakErr2 pakReadHeaderAtOffset(s8 device, u32 offset, struct pakfileheader *heade
859859
return PAK_ERR2_BADOFFSET;
860860
}
861861

862+
if (offset > g_Paks[device].pdnumbytes - sizeof(sp38)) {
863+
// not enough bytes left for a header
864+
return PAK_ERR2_BADOFFSET;
865+
}
866+
862867
if (!pakRetrieveHeaderFromCache(device, blocknum, headerptr)) {
863868
result = pakReadWriteBlock(device, PFS(device), g_Paks[device].pdnoteindex, 0, offset, sizeof(sp38), sp38);
864869

0 commit comments

Comments
 (0)