nicoboss/nsz

'\x00'.join(file['name'] for file in self.files) doesn't append null terminator to string table

chetrr opened this issue · 9 comments

Since .join() doesn't append the final byte, the string table calculations are off by one for HFS0. This bug causes DBI installation to error and also causes libhac to fail Sha256PartitionFileSystem checks in the latest 19.0 tag, since they both parse string table entries.

This may be related to recent changes in Pfs0.py.

Since .join() doesn't append the final byte, the string table calculations are off by one for HFS0. This bug causes DBI installation to error and also causes libhac to fail Sha256PartitionFileSystem checks in the latest 19.0 tag, since they both parse string table entries.

This may be related to recent changes in Pfs0.py.

Oh sorry this is really bad. This likely was caused by the changes made in the latest version. Please downgrade to NSZ v4.4.0 and see if it works there. I will fix this as soon as possible. Did you use the --remove-padding command line option?

I see this is so stupid:

stringTable = '\x00'.join(file['name'] for file in self.files)

This obviosuly has to be:

stringTable = '\x00'.join(file['name'] for file in self.files)+'\x00'

Sorry again for this. I unfortunately don’t have the time and resources to make sure that every release is compatible with every title installer out there. To fix your existing NSZ/XCZ files just decompress and recompress them using latest master.

Thanks for the quick turnaround, I appreciate all the work you do on this project!

Hi @nicoboss! I would love to see this released soon. 🙏
I have started processing my entire NSP collection with nsz v4.5.0 without being aware of this bug. Now, resulting files are not processable by hactool anymore (buffer overflow here because last filename is not null-terminated).
Of course there is a workaround, but releasing a new version may help people avoiding this.

Hi @nicoboss! I would love to see this released soon. 🙏 I have started processing my entire NSP collection with nsz v4.5.0 without being aware of this bug. Now, resulting files are not processable by hactool anymore (buffer overflow here because last filename is not null-terminated). Of course there is a workaround, but releasing a new version may help people avoiding this.

I'm really sorry for this. While this was fixed almost a month ago, I never made a new release since. I will try my best to create another release this weekend. I just really want to fix #150 and merge #160 before I do.

Thanks for your answer!
No worries, take your time, I just wanted to let you know a new release would be useful. 😉
BTW, many thanks for your hard work on this tool!

@connesc and @chetrr I'm happy to let you know that this fix is now in the latest NSZ 4.6.0 release. Sorry that it took so long for this fix to make it into a released. I wanted to release this fix together with proper PFS0 padding and the major XCI/XCZ rewrite so all file system changes are in a single release. File system changes are by far the most critical so a lot of testing was performed during which many other issues were found that had to be fixed before the release. Thanks @connesc for pushing me to work hard on this release or it likely wouldn't have happened this year.

It feels like Christmas before Christmas! 😄
I am happy to read that my messages motivated you. And please @nicoboss don't apologize for the delay. I am really impressed by your commitment to this project, thank you very much for your work! 👍👍