From 347677c3330ece8496b9cd242fd7e4292c2260ae Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 24 Apr 2026 15:55:21 -0400 Subject: NUL terminate after copy --- tests/test_relocation.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/test_relocation.c') diff --git a/tests/test_relocation.c b/tests/test_relocation.c index 69142dc..3454a69 100644 --- a/tests/test_relocation.c +++ b/tests/test_relocation.c @@ -15,6 +15,7 @@ void test_replace_text() { const char *expected = targets[i + 1]; char input[BUFSIZ] = {0}; strncpy(input, test_string, sizeof(input) - 1); + input[sizeof(input) - 1] = '\0'; printf("input: %s\n", input); printf("target: %s\n", target); -- cgit From 421903a1379353f07a10deb335ed3c0361233064 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 26 Apr 2026 01:49:02 -0400 Subject: Fix file handle leaks --- tests/test_relocation.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/test_relocation.c') diff --git a/tests/test_relocation.c b/tests/test_relocation.c index 3454a69..4a02e01 100644 --- a/tests/test_relocation.c +++ b/tests/test_relocation.c @@ -40,6 +40,7 @@ void test_file_replace_text() { STASIS_ASSERT(file_replace_text(filename, target, "^^^", 0) == 0, "string replacement failed"); } else { STASIS_ASSERT(false, "failed to open file for writing"); + fclose(fp); return; } @@ -48,8 +49,10 @@ void test_file_replace_text() { if (fp) { fread(input, sizeof(*input), sizeof(input), fp); STASIS_ASSERT(strcmp(input, expected) == 0, "unexpected replacement"); + fclose(fp); } else { STASIS_ASSERT(false, "failed to open file for reading"); + fclose(fp); return; } } -- cgit