From ca84fc0fb9aaac135c04dccada6e197e3eb084de Mon Sep 17 00:00:00 2001 From: Bobby Battista Date: Thu, 2 Apr 2026 18:09:14 -0500 Subject: [PATCH 1/4] bugfix(targa): Fix TGA2 footer signature truncation by using memcpy --- Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp b/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp index bc32d1ecfd5..4b8f79c1fc7 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp @@ -735,7 +735,7 @@ long Targa::Save(const char* name, long flags, bool addextension) if (!error) { footer.Developer = 0; - strlcpy(footer.Signature, TGA2_SIGNATURE, sizeof(footer.Signature)); + memcpy(footer.Signature, TGA2_SIGNATURE, sizeof(footer.Signature)); // TheSuperHackers @bugfix bobtista 02/04/2026 Use memcpy to copy all 16 bytes of the TGA2 signature without null termination, as the field is a fixed-size binary field per the TGA 2.0 spec footer.RsvdChar = '.'; footer.BZST = 0; From 48949fa4dc1234f1934b8bcae98bb122bf88371a Mon Sep 17 00:00:00 2001 From: Bobby Battista Date: Fri, 3 Apr 2026 10:58:31 -0400 Subject: [PATCH 2/4] fix(targa): Address review comments - use strncpy, add static assert, fix strcpy --- Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp b/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp index 4b8f79c1fc7..26a9f672c09 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp @@ -713,7 +713,7 @@ long Targa::Save(const char* name, long flags, bool addextension) if (!error) { mExtension.ExtSize = 495; - strcpy(mExtension.SoftID, "Denzil's Targa Code"); + strlcpy_t(mExtension.SoftID, "Denzil's Targa Code"); // TheSuperHackers @fix bobtista 03/04/2026 Replace strcpy with strlcpy_t mExtension.SoftVer.Number = (1 * 100); mExtension.SoftVer.Letter = 0; @@ -735,7 +735,8 @@ long Targa::Save(const char* name, long flags, bool addextension) if (!error) { footer.Developer = 0; - memcpy(footer.Signature, TGA2_SIGNATURE, sizeof(footer.Signature)); // TheSuperHackers @bugfix bobtista 02/04/2026 Use memcpy to copy all 16 bytes of the TGA2 signature without null termination, as the field is a fixed-size binary field per the TGA 2.0 spec + static_assert(sizeof(TGA2_SIGNATURE) - 1 == sizeof(footer.Signature), "TGA2 signature length mismatch"); // TheSuperHackers @bugfix bobtista 02/04/2026 Verify TGA2 signature sizes match + strncpy(footer.Signature, TGA2_SIGNATURE, sizeof(footer.Signature)); footer.RsvdChar = '.'; footer.BZST = 0; From 635497997c53101584b4bef96eda9f54d440743d Mon Sep 17 00:00:00 2001 From: Bobby Battista Date: Fri, 3 Apr 2026 11:00:57 -0400 Subject: [PATCH 3/4] fix(targa): Remove superfluous comments --- Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp b/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp index 26a9f672c09..142ee7da72d 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp @@ -713,7 +713,7 @@ long Targa::Save(const char* name, long flags, bool addextension) if (!error) { mExtension.ExtSize = 495; - strlcpy_t(mExtension.SoftID, "Denzil's Targa Code"); // TheSuperHackers @fix bobtista 03/04/2026 Replace strcpy with strlcpy_t + strlcpy_t(mExtension.SoftID, "Denzil's Targa Code"); mExtension.SoftVer.Number = (1 * 100); mExtension.SoftVer.Letter = 0; @@ -735,7 +735,7 @@ long Targa::Save(const char* name, long flags, bool addextension) if (!error) { footer.Developer = 0; - static_assert(sizeof(TGA2_SIGNATURE) - 1 == sizeof(footer.Signature), "TGA2 signature length mismatch"); // TheSuperHackers @bugfix bobtista 02/04/2026 Verify TGA2 signature sizes match + static_assert(sizeof(TGA2_SIGNATURE) - 1 == sizeof(footer.Signature), "TGA2 signature length mismatch"); strncpy(footer.Signature, TGA2_SIGNATURE, sizeof(footer.Signature)); footer.RsvdChar = '.'; footer.BZST = 0; From ab8ad08244f7f07bbaf4afd21cb403cc95ff0f3d Mon Sep 17 00:00:00 2001 From: Bobby Battista Date: Fri, 3 Apr 2026 11:05:47 -0400 Subject: [PATCH 4/4] fix(targa): Use strlcpy with explicit size for VC6 compatibility --- Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp b/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp index 142ee7da72d..4c4d1e1d6ee 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp @@ -713,7 +713,7 @@ long Targa::Save(const char* name, long flags, bool addextension) if (!error) { mExtension.ExtSize = 495; - strlcpy_t(mExtension.SoftID, "Denzil's Targa Code"); + strlcpy(mExtension.SoftID, "Denzil's Targa Code", sizeof(mExtension.SoftID)); mExtension.SoftVer.Number = (1 * 100); mExtension.SoftVer.Letter = 0;