aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-10-01 15:42:41 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-10-01 15:42:41 -0400
commite462c06cae9f75526fa200531615bdcc47716eef (patch)
treebef6687876eab41129f10a1bc078c4dd27d74498
parent1ba1fcc61a200c833f4a89849dd9d2577693bfa0 (diff)
downloadstasis-e462c06cae9f75526fa200531615bdcc47716eef.tar.gz
Add missing space to destdir to ensure its separate from the srcdir string
* Fix leaks caused by css_filename path and the dirs array
-rw-r--r--src/stasis_indexer.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/stasis_indexer.c b/src/stasis_indexer.c
index 8ee575e..b38c8d0 100644
--- a/src/stasis_indexer.c
+++ b/src/stasis_indexer.c
@@ -72,9 +72,9 @@ int indexer_combine_rootdirs(const char *dest, char **rootdirs, const size_t roo
if (!access(srcdir_with_output, F_OK)) {
srcdir = srcdir_with_output;
}
- sprintf(cmd + strlen(cmd), "'%s'/ ", srcdir);
+ snprintf(cmd + strlen(cmd), sizeof(srcdir) - strlen(srcdir) + 4, "'%s'/ ", srcdir);
}
- sprintf(cmd + strlen(cmd), "%s/", destdir);
+ snprintf(cmd + strlen(cmd), sizeof(cmd) - strlen(destdir) + 1, " %s/", destdir);
if (globals.verbose) {
puts(cmd);
@@ -368,6 +368,8 @@ int indexer_make_website(struct Delivery *ctx) {
// This might be negative when killed by a signal.
// Otherwise, the return code is not critical to us.
if (system(cmd) < 0) {
+ guard_free(css_filename);
+ guard_strlist_free(&dirs);
return 1;
}
if (file_replace_text(fullpath_dest, ".md", ".html", 0)) {
@@ -388,6 +390,7 @@ int indexer_make_website(struct Delivery *ctx) {
}
guard_strlist_free(&inputs);
}
+ guard_free(css_filename);
guard_strlist_free(&dirs);
return 0;