From 3048cde1187eba77c2dbd9bd42a451db61e2aebc Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 6 Mar 2023 23:45:51 -0700 Subject: [PATCH] hac2l: fix keys not working without newline at eof --- source/hactool_processor.keys.cpp | 5 ++++- source/hactool_processor.nca.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/source/hactool_processor.keys.cpp b/source/hactool_processor.keys.cpp index 8a918a7..465ad14 100644 --- a/source/hactool_processor.keys.cpp +++ b/source/hactool_processor.keys.cpp @@ -470,7 +470,7 @@ namespace ams::hactool { } /* Allocate buffer for the file. */ - auto buf = std::make_unique(file_size); + auto buf = std::make_unique(file_size + 1); if (buf == nullptr) { fprintf(stderr, "[Warning]: failed to allocate memory for key file (%s)\n", path); return; @@ -482,6 +482,9 @@ namespace ams::hactool { return; } + /* Null-terminate the file contents. */ + buf[file_size] = '\x00'; + ProcessKeyValueFile(path, buf.get(), file_size, f); } diff --git a/source/hactool_processor.nca.cpp b/source/hactool_processor.nca.cpp index 7f13905..1ce8718 100644 --- a/source/hactool_processor.nca.cpp +++ b/source/hactool_processor.nca.cpp @@ -156,7 +156,7 @@ namespace ams::hactool { } if (m_has_base_pfs && !m_base_pfs_ctx.is_exefs) { - m_has_base_xci = false; + m_has_base_pfs = false; GetBaseFromAppFs(m_base_pfs_ctx.app_ctx, "basepfs"); m_has_base_pfs = true; }