Skip to content

Commit 69b7882

Browse files
authored
fix(targa): Fix TGA2 footer signature truncation by using strncpy (TheSuperHackers#2527)
1 parent 3fac0c7 commit 69b7882

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ long Targa::Save(const char* name, long flags, bool addextension)
713713
if (!error) {
714714

715715
mExtension.ExtSize = 495;
716-
strcpy(mExtension.SoftID, "Denzil's Targa Code");
716+
strlcpy(mExtension.SoftID, "Denzil's Targa Code", sizeof(mExtension.SoftID));
717717
mExtension.SoftVer.Number = (1 * 100);
718718
mExtension.SoftVer.Letter = 0;
719719

@@ -735,7 +735,8 @@ long Targa::Save(const char* name, long flags, bool addextension)
735735
if (!error)
736736
{
737737
footer.Developer = 0;
738-
strlcpy(footer.Signature, TGA2_SIGNATURE, sizeof(footer.Signature));
738+
static_assert(sizeof(TGA2_SIGNATURE) - 1 == sizeof(footer.Signature), "TGA2 signature length mismatch");
739+
strncpy(footer.Signature, TGA2_SIGNATURE, sizeof(footer.Signature));
739740
footer.RsvdChar = '.';
740741
footer.BZST = 0;
741742

0 commit comments

Comments
 (0)