From 081da8afbfbd808acecc1d3e54f89b90c625ee77 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 29 Apr 2026 12:41:28 -0400 Subject: handle asprintf errors --- src/cli/stasis_indexer/helpers.c | 5 ++++- src/cli/stasis_indexer/readmes.c | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/cli') diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c index 097b0ca..bf7efee 100644 --- a/src/cli/stasis_indexer/helpers.c +++ b/src/cli/stasis_indexer/helpers.c @@ -297,7 +297,10 @@ int get_files(struct StrList **out, const char *path, const char *pattern, ...) struct StrList *get_docker_images(struct Delivery *ctx, char *pattern) { char *tarball = NULL; - asprintf(&tarball, "%s*.tar*", pattern); + if (asprintf(&tarball, "%s*.tar*", pattern) < 0) { + SYSERROR("unable to allocate bytes for tarball pattern: %s", pattern); + return NULL; + } if (!tarball) { SYSERROR("Unable to allocate bytes for docker image wildcard pattern"); return NULL; diff --git a/src/cli/stasis_indexer/readmes.c b/src/cli/stasis_indexer/readmes.c index de9e2f2..836df5c 100644 --- a/src/cli/stasis_indexer/readmes.c +++ b/src/cli/stasis_indexer/readmes.c @@ -101,10 +101,9 @@ int indexer_readmes(struct Delivery **ctx, const size_t nelem) { fprintf(indexfp, "- Receipt: [STASIS input file](../config/%s.ini)\n", current->info.release_name); char *pattern = NULL; - asprintf(&pattern, "*%s*%s*", + if (asprintf(&pattern, "*%s*%s*", current->info.build_number, - strstr((*ctx)->rules.release_fmt, "%p") ? current->meta.python_compact : "" ); - if (!pattern) { + strstr((*ctx)->rules.release_fmt, "%p") ? current->meta.python_compact : "" ) < 0) { SYSERROR("Unable to allocate bytes for pattern"); fclose(indexfp); return -1; -- cgit From 9732a6fca438f719eb9e7c9f48e9df726743a9ea Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 29 Apr 2026 13:18:40 -0400 Subject: write_report_output: fail on allocation errors --- src/cli/stasis_indexer/junitxml_report.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/cli') diff --git a/src/cli/stasis_indexer/junitxml_report.c b/src/cli/stasis_indexer/junitxml_report.c index 073bb61..891fe8a 100644 --- a/src/cli/stasis_indexer/junitxml_report.c +++ b/src/cli/stasis_indexer/junitxml_report.c @@ -31,6 +31,10 @@ static int write_report_output(struct Delivery *ctx, FILE *destfp, const char *x char *bname_tmp = strdup(xmlfilename); char *bname = strdup(path_basename(bname_tmp)); + if (!bname) { + SYSERROR("%s", "unable to allocate bytes for basename"); + return -1; + } if (endswith(bname, ".xml")) { bname[strlen(bname) - 4] = 0; } -- cgit From 0557219fbfe52cfb284f62b37e0bcce111a57cf0 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 29 Apr 2026 14:28:36 -0400 Subject: Subtract remaining characters in format string --- src/cli/stasis_indexer/stasis_indexer_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/cli') diff --git a/src/cli/stasis_indexer/stasis_indexer_main.c b/src/cli/stasis_indexer/stasis_indexer_main.c index 2bf72fd..86cace5 100644 --- a/src/cli/stasis_indexer/stasis_indexer_main.c +++ b/src/cli/stasis_indexer/stasis_indexer_main.c @@ -48,9 +48,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; } - snprintf(cmd + strlen(cmd), sizeof(cmd) - strlen(cmd), "'%s'/ ", srcdir); + snprintf(cmd + strlen(cmd), sizeof(cmd) - strlen(cmd) - non_format_len("'%s'/ "), "'%s'/ ", srcdir); } - snprintf(cmd + strlen(cmd), sizeof(cmd) - strlen(cmd), " %s/", destdir); + snprintf(cmd + strlen(cmd), sizeof(cmd) - strlen(cmd) - non_format_len(" %s/"), " %s/", destdir); if (globals.verbose) { puts(cmd); -- cgit From 657d1cd403a4d97c73260eae1e689e55ff324895 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 29 Apr 2026 14:29:49 -0400 Subject: maxwidth will fit --- src/cli/stasis/stasis_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/cli') diff --git a/src/cli/stasis/stasis_main.c b/src/cli/stasis/stasis_main.c index b902a8a..553d275 100644 --- a/src/cli/stasis/stasis_main.c +++ b/src/cli/stasis/stasis_main.c @@ -551,12 +551,11 @@ static char *center_text(const char *s, const size_t maxwidth) { } result[i++] = 'v'; strncpy(&result[i], s, maxwidth - middle - 1); - result[maxwidth - 1] = '\0'; + result[maxwidth] = '\0'; return result; } - int main(int argc, char *argv[]) { struct Delivery ctx; struct Process proc = { -- cgit From 79cbdf3b3ea5a38791cad816d650b542df6b4cbc Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 30 Apr 2026 09:42:06 -0400 Subject: Add message before running micromamba configuration --- src/cli/stasis_indexer/stasis_indexer_main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/cli') diff --git a/src/cli/stasis_indexer/stasis_indexer_main.c b/src/cli/stasis_indexer/stasis_indexer_main.c index 86cace5..071057a 100644 --- a/src/cli/stasis_indexer/stasis_indexer_main.c +++ b/src/cli/stasis_indexer/stasis_indexer_main.c @@ -325,6 +325,7 @@ int main(const int argc, char *argv[]) { mkdirs(ctx.storage.wheel_artifact_dir, 0755); } + msg(STASIS_MSG_L1, "Configure Micromamba\n"); struct MicromambaInfo m; if (micromamba_configure(&ctx, &m)) { SYSERROR("Unable to configure micromamba"); -- cgit From 8f91345c4284ed6c882c38e961be106e72418ec8 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 30 Apr 2026 09:43:55 -0400 Subject: Move center_text function into utils.c/utils.h * Remove 'v' prefix * Print version the same way in the indexer --- src/cli/stasis_indexer/stasis_indexer_main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/cli') diff --git a/src/cli/stasis_indexer/stasis_indexer_main.c b/src/cli/stasis_indexer/stasis_indexer_main.c index 071057a..e87122e 100644 --- a/src/cli/stasis_indexer/stasis_indexer_main.c +++ b/src/cli/stasis_indexer/stasis_indexer_main.c @@ -304,7 +304,17 @@ int main(const int argc, char *argv[]) { struct Delivery ctx = {0}; - printf(BANNER, VERSION, AUTHOR); + char *version = center_text(VERSION, strlen(STASIS_BANNER_HEADER)); + if (!version) { + SYSERROR("%s", "version too long?"); + version = strdup(VERSION); + if (!version) { + SYSERROR("%s", "unable to allocate uncentered fallback version string"); + exit(1); + } + } + printf(BANNER, version, AUTHOR); + guard_free(version); indexer_init_dirs(&ctx, workdir); -- cgit From f467de54062fed57c37de53d1e89794b5e9eee2a Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 1 May 2026 19:01:03 -0400 Subject: explicitly check if option name is NULL --- src/cli/stasis/args.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cli') diff --git a/src/cli/stasis/args.c b/src/cli/stasis/args.c index e1c49fe..eb096bc 100644 --- a/src/cli/stasis/args.c +++ b/src/cli/stasis/args.c @@ -59,7 +59,7 @@ static int get_option_max_width(struct option option[]) { int i = 0; int max = 0; const int indent = 4; - while (option[i].name != 0) { + while (option[i].name != NULL) { int len = (int) strlen(option[i].name); if (option[i].has_arg) { len += indent; -- cgit From 398c71a07c84312d7438974d178a0358d3713e2b Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 10 May 2026 17:04:41 -0400 Subject: Error check --- src/cli/stasis_indexer/junitxml_report.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/cli') diff --git a/src/cli/stasis_indexer/junitxml_report.c b/src/cli/stasis_indexer/junitxml_report.c index 891fe8a..909bf1d 100644 --- a/src/cli/stasis_indexer/junitxml_report.c +++ b/src/cli/stasis_indexer/junitxml_report.c @@ -30,11 +30,17 @@ static int write_report_output(struct Delivery *ctx, FILE *destfp, const char *x } char *bname_tmp = strdup(xmlfilename); + if (!bname_tmp) { + SYSERROR("%s", "unable to allocate bytes for temporary basename"); + return -1; + } + char *bname = strdup(path_basename(bname_tmp)); if (!bname) { SYSERROR("%s", "unable to allocate bytes for basename"); return -1; } + if (endswith(bname, ".xml")) { bname[strlen(bname) - 4] = 0; } -- cgit From 9df56118210af2ae0af8d735e85b391828b5d289 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 10 May 2026 20:10:24 -0400 Subject: How did you get back in there... --- src/cli/stasis/stasis_main.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'src/cli') diff --git a/src/cli/stasis/stasis_main.c b/src/cli/stasis/stasis_main.c index 553d275..fb4ed80 100644 --- a/src/cli/stasis/stasis_main.c +++ b/src/cli/stasis/stasis_main.c @@ -522,40 +522,6 @@ static void transfer_artifacts(struct Delivery *ctx) { } } -static char *center_text(const char *s, const size_t maxwidth) { - if (maxwidth < 2) { - SYSERROR("maximum width must be greater than 0"); - return NULL; - } - - if (maxwidth % 2 != 0) { - SYSERROR("maximum width (%zu) must be even", maxwidth); - return NULL; - } - - const size_t s_len = strlen(s); - if (s_len + 1 > maxwidth) { - SYSERROR("length of input string (%zu) exceeds maximum width (%zu)", s_len, maxwidth); - return NULL; - } - - char *result = calloc(maxwidth + 1, sizeof(*result)); - if (!result) { - SYSERROR("unable to allocate bytes for centered text string"); - return NULL; - } - const size_t middle = (maxwidth / 2) - s_len / 2; - size_t i = 0; - for (; i < middle; i++) { - result[i] = ' '; - } - result[i++] = 'v'; - strncpy(&result[i], s, maxwidth - middle - 1); - result[maxwidth] = '\0'; - - return result; -} - int main(int argc, char *argv[]) { struct Delivery ctx; struct Process proc = { -- cgit From 98d50a05c62b772a6c391d05f175f44d8764c8a5 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 10 May 2026 21:37:13 -0400 Subject: Update SYS_* macros --- src/cli/stasis_indexer/junitxml_report.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/cli') diff --git a/src/cli/stasis_indexer/junitxml_report.c b/src/cli/stasis_indexer/junitxml_report.c index 909bf1d..a7dcd06 100644 --- a/src/cli/stasis_indexer/junitxml_report.c +++ b/src/cli/stasis_indexer/junitxml_report.c @@ -31,13 +31,13 @@ static int write_report_output(struct Delivery *ctx, FILE *destfp, const char *x char *bname_tmp = strdup(xmlfilename); if (!bname_tmp) { - SYSERROR("%s", "unable to allocate bytes for temporary basename"); + SYSERROR("unable to allocate bytes for temporary basename"); return -1; } char *bname = strdup(path_basename(bname_tmp)); if (!bname) { - SYSERROR("%s", "unable to allocate bytes for basename"); + SYSERROR("unable to allocate bytes for basename"); return -1; } -- cgit From 8217fc2354f4614ed64f7b5530fbc9d155b697b5 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 12 May 2026 10:52:51 -0400 Subject: exit on error --- src/cli/stasis/system_requirements.c | 91 ++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 14 deletions(-) (limited to 'src/cli') diff --git a/src/cli/stasis/system_requirements.c b/src/cli/stasis/system_requirements.c index 02889da..b531ae1 100644 --- a/src/cli/stasis/system_requirements.c +++ b/src/cli/stasis/system_requirements.c @@ -3,20 +3,83 @@ void check_system_env_requirements() { msg(STASIS_MSG_L1, "Checking environment\n"); globals.envctl = envctl_init(); - envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "TMPDIR"); - envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_ROOT"); - envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_SYSCONFDIR"); - envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_CPU_COUNT"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED | STASIS_ENVCTL_REDACT, callback_except_gh, "STASIS_GH_TOKEN"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED, callback_except_jf, "STASIS_JF_ARTIFACTORY_URL"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_ACCESS_TOKEN"); - envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_JF_USER"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_PASSWORD"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_SSH_KEY_PATH"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_SSH_PASSPHRASE"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_CLIENT_CERT_CERT_PATH"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_CLIENT_CERT_KEY_PATH"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED, callback_except_jf, "STASIS_JF_REPO"); + if (!globals.envctl) { + SYSERROR("envctl_init failed"); + exit(1); + } + + int status = 0; + status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "TMPDIR"); + if (!status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_ROOT"); + if (!status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_SYSCONFDIR"); + if (!status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_CPU_COUNT"); + if (!status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED | STASIS_ENVCTL_REDACT, callback_except_gh, "STASIS_GH_TOKEN"); + if (!status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED, callback_except_jf, "STASIS_JF_ARTIFACTORY_URL"); + if (!status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_ACCESS_TOKEN"); + if (!status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_JF_USER"); + if (!status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_PASSWORD"); + if (!status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_SSH_KEY_PATH"); + if (!status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_SSH_PASSPHRASE"); + if (!status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_CLIENT_CERT_CERT_PATH"); + if (!status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_CLIENT_CERT_KEY_PATH"); + if (!status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED, callback_except_jf, "STASIS_JF_REPO"); + if (!status) { + SYSERROR("envctl_register failed"); + exit(1); + } + envctl_do_required(globals.envctl, globals.verbose); } -- cgit From 45d8e2aeb737a5d3b91217a01f81392341f190d2 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 12 May 2026 11:14:06 -0400 Subject: Reverse logic on status check --- src/cli/stasis/system_requirements.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/cli') diff --git a/src/cli/stasis/system_requirements.c b/src/cli/stasis/system_requirements.c index b531ae1..a48c113 100644 --- a/src/cli/stasis/system_requirements.c +++ b/src/cli/stasis/system_requirements.c @@ -10,72 +10,72 @@ void check_system_env_requirements() { int status = 0; status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "TMPDIR"); - if (!status) { + if (status) { SYSERROR("envctl_register failed"); exit(1); } status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_ROOT"); - if (!status) { + if (status) { SYSERROR("envctl_register failed"); exit(1); } status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_SYSCONFDIR"); - if (!status) { + if (status) { SYSERROR("envctl_register failed"); exit(1); } status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_CPU_COUNT"); - if (!status) { + if (status) { SYSERROR("envctl_register failed"); exit(1); } status = envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED | STASIS_ENVCTL_REDACT, callback_except_gh, "STASIS_GH_TOKEN"); - if (!status) { + if (status) { SYSERROR("envctl_register failed"); exit(1); } status = envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED, callback_except_jf, "STASIS_JF_ARTIFACTORY_URL"); - if (!status) { + if (status) { SYSERROR("envctl_register failed"); exit(1); } status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_ACCESS_TOKEN"); - if (!status) { + if (status) { SYSERROR("envctl_register failed"); exit(1); } status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_JF_USER"); - if (!status) { + if (status) { SYSERROR("envctl_register failed"); exit(1); } status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_PASSWORD"); - if (!status) { + if (status) { SYSERROR("envctl_register failed"); exit(1); } status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_SSH_KEY_PATH"); - if (!status) { + if (status) { SYSERROR("envctl_register failed"); exit(1); } status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_SSH_PASSPHRASE"); - if (!status) { + if (status) { SYSERROR("envctl_register failed"); exit(1); } status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_CLIENT_CERT_CERT_PATH"); - if (!status) { + if (status) { SYSERROR("envctl_register failed"); exit(1); } status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_CLIENT_CERT_KEY_PATH"); - if (!status) { + if (status) { SYSERROR("envctl_register failed"); exit(1); } status = envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED, callback_except_jf, "STASIS_JF_REPO"); - if (!status) { + if (status) { SYSERROR("envctl_register failed"); exit(1); } -- cgit From d89f776c1d55fa6ad41b5dcf870d03256a4f54a7 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 12 May 2026 12:32:18 -0400 Subject: Remove redundant __FUNCTION__ --- src/cli/stasis_indexer/helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cli') diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c index bf7efee..92e2dd4 100644 --- a/src/cli/stasis_indexer/helpers.c +++ b/src/cli/stasis_indexer/helpers.c @@ -257,7 +257,7 @@ int get_files(struct StrList **out, const char *path, const char *pattern, ...) return -1; } if ((size_t) len > sizeof(userpattern)) { - SYSWARN("%s: userpattern truncated!", __FUNCTION__); + SYSWARN("userpattern truncated!"); } va_end(args); if (!strlen(userpattern)) { -- cgit