Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
chetrr opened this issue Nov 9, 2023 · 9 comments · Fixed by #152
Assignees
Labels
bug Something isn't working file format Issues with the NSZ file format
Milestone

Comments

@chetrr
Copy link

chetrr commented Nov 9, 2023

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.

@nicoboss
Copy link
Owner

nicoboss commented Nov 9, 2023

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?

@nicoboss
Copy link
Owner

nicoboss commented Nov 9, 2023

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'

@nicoboss
Copy link
Owner

nicoboss commented Nov 9, 2023

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.

@nicoboss nicoboss self-assigned this Nov 9, 2023
@nicoboss nicoboss added bug Something isn't working file format Issues with the NSZ file format labels Nov 9, 2023
@nicoboss nicoboss added this to the v4.6 milestone Nov 9, 2023
@chetrr
Copy link
Author

chetrr commented Nov 9, 2023

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

@connesc
Copy link

connesc commented Dec 1, 2023

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.

@nicoboss
Copy link
Owner

nicoboss commented Dec 1, 2023

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.

@connesc
Copy link

connesc commented Dec 1, 2023

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!

@nicoboss
Copy link
Owner

@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.

@connesc
Copy link

connesc commented Dec 21, 2023

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! 👍👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working file format Issues with the NSZ file format
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants