aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2025-01-30 23:47:05 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2025-01-30 23:47:05 -0500
commit661099bd8da61f97fc3f775dfe1ec5d088fd730d (patch)
tree72d84d5eeff179b927c9f84ac29d0778e77a5de6
parentb366b477b5d7b740212987113f27e9161734f124 (diff)
downloadstasis-661099bd8da61f97fc3f775dfe1ec5d088fd730d.tar.gz
Duplicate basename to avoid invalid read
-rw-r--r--src/cli/stasis_indexer/junitxml_report.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cli/stasis_indexer/junitxml_report.c b/src/cli/stasis_indexer/junitxml_report.c
index d7d8f9a..c3da168 100644
--- a/src/cli/stasis_indexer/junitxml_report.c
+++ b/src/cli/stasis_indexer/junitxml_report.c
@@ -28,7 +28,7 @@ static int write_report_output(struct Delivery *ctx, FILE *destfp, const char *x
}
char *bname_tmp = strdup(xmlfilename);
- char *bname = path_basename(bname_tmp);
+ char *bname = strdup(path_basename(bname_tmp));
if (endswith(bname, ".xml")) {
bname[strlen(bname) - 4] = 0;
}
@@ -51,6 +51,8 @@ static int write_report_output(struct Delivery *ctx, FILE *destfp, const char *x
snprintf(result_outfile, sizeof(result_outfile) - strlen(bname) - 3, "%s.md",
bname);
+ guard_free(bname);
+
FILE *resultfp = fopen(result_outfile, "w+");
if (!resultfp) {
SYSERROR("Unable to open %s for writing", result_outfile);