From a7300b0fa40e25c090315ca3518a905c87739db9 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 19 Apr 2023 01:08:37 -0400 Subject: [PATCH] haze: fix file size transmission issue --- troposphere/haze/source/ptp_responder.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/troposphere/haze/source/ptp_responder.cpp b/troposphere/haze/source/ptp_responder.cpp index 22d732cc0..6086c2cce 100644 --- a/troposphere/haze/source/ptp_responder.cpp +++ b/troposphere/haze/source/ptp_responder.cpp @@ -722,7 +722,9 @@ namespace haze { R_TRY(m_fs.SetFileSize(std::addressof(file), 0)); /* Expand to the needed size. */ - R_TRY(m_fs.SetFileSize(std::addressof(file), data_header.length)); + if (data_header.length > sizeof(PtpUsbBulkContainer)) { + R_TRY(m_fs.SetFileSize(std::addressof(file), data_header.length - sizeof(PtpUsbBulkContainer))); + } /* Begin writing to the filesystem. */ while (true) { @@ -743,6 +745,9 @@ namespace haze { R_TRY(read_res); } + /* Truncate the file to the received size. */ + R_TRY(m_fs.SetFileSize(std::addressof(file), offset)); + /* Write the success response. */ R_RETURN(this->WriteResponse(PtpResponseCode_Ok)); }