From 73ea20d29c48666c77152637bbb364b3692cf5a5 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 10 Jul 2022 00:57:21 -0700 Subject: [PATCH] hac2l: fix oob when printing progress on certain files --- source/hactool_fs_utils.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/hactool_fs_utils.cpp b/source/hactool_fs_utils.cpp index ef2af0f..13825dd 100644 --- a/source/hactool_fs_utils.cpp +++ b/source/hactool_fs_utils.cpp @@ -575,7 +575,8 @@ namespace ams::hactool { ProgressPrinter<40> printer{prog_prefix, static_cast(size)}; /* Write. */ - const s64 end_offset = static_cast(offset + size); + const s64 start_offset = offset; + const s64 end_offset = static_cast(offset + size); while (offset < end_offset) { const s64 cur_write_size = std::min(WorkBufferSize, end_offset - offset); @@ -583,7 +584,7 @@ namespace ams::hactool { R_TRY(base_file->Write(offset, buffer, cur_write_size, fs::WriteOption::None)); offset += cur_write_size; - printer.Update(static_cast(offset)); + printer.Update(static_cast(offset - start_offset)); } R_SUCCEED();