From 56c01ac806bb80ca20f38e1cebc9682849201076 Mon Sep 17 00:00:00 2001 From: seiya-git Date: Mon, 1 Jan 2024 12:09:30 +0300 Subject: [PATCH] Fixed some logic responsible to handle too short PFS0 header sizes --- py/nstools/Fs/Pfs0.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/py/nstools/Fs/Pfs0.py b/py/nstools/Fs/Pfs0.py index c4fab14..a42d251 100644 --- a/py/nstools/Fs/Pfs0.py +++ b/py/nstools/Fs/Pfs0.py @@ -77,8 +77,8 @@ def getStringTableSize(self): stringTableSizePadded = len(stringTableNonPadded) + self.allign0x20(headerSizeNonPadded) if self._stringTableSize == None: self._stringTableSize = stringTableSizePadded - if stringTableSizePadded > self._stringTableSize: - self._stringTableSize = stringTableSizePadded + elif len(stringTableNonPadded) > self._stringTableSize: + self._stringTableSize = len(stringTableNonPadded) return self._stringTableSize def getFirstFileOffset(self): @@ -156,8 +156,8 @@ def getStringTableSize(self): stringTableSizePadded = len(stringTableNonPadded) + self.allign0x20(headerSizeNonPadded) if self._stringTableSize == None: self._stringTableSize = stringTableSizePadded - if stringTableSizePadded > self._stringTableSize: - self._stringTableSize = stringTableSizePadded + elif len(stringTableNonPadded) > self._stringTableSize: + self._stringTableSize = len(stringTableNonPadded) return self._stringTableSize def getHash(self): @@ -173,7 +173,7 @@ def getHeaderHash(self): h = b'' h += b'PFS0' h += len(self.files).to_bytes(4, byteorder='little') - h += (self.getStringTableSize()).to_bytes(4, byteorder='little') + h += (stringTableSizePadded).to_bytes(4, byteorder='little') h += b'\x00\x00\x00\x00' stringOffset = 0