From 0de2a305fc2187f62b3df36d7541e7f4fa254f61 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 20 Sep 2024 08:45:20 -0400 Subject: Fix string op warnings * Fix unused-result warnings --- src/stasis_indexer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/stasis_indexer.c') diff --git a/src/stasis_indexer.c b/src/stasis_indexer.c index ef6375b..8ee575e 100644 --- a/src/stasis_indexer.c +++ b/src/stasis_indexer.c @@ -381,7 +381,9 @@ int indexer_make_website(struct Delivery *ctx) { char link_dest[PATH_MAX] = {0}; strcpy(link_from, "README.html"); sprintf(link_dest, "%s/%s", root, "index.html"); - symlink(link_from, link_dest); + if (symlink(link_from, link_dest)) { + SYSERROR("Warning: symlink(%s, %s) failed: %s", link_from, link_dest, strerror(errno)); + } } } guard_strlist_free(&inputs); -- cgit From e462c06cae9f75526fa200531615bdcc47716eef Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 1 Oct 2024 15:42:41 -0400 Subject: Add missing space to destdir to ensure its separate from the srcdir string * Fix leaks caused by css_filename path and the dirs array --- src/stasis_indexer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/stasis_indexer.c') 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; -- cgit