aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2026-04-29 12:41:28 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2026-04-29 12:41:28 -0400
commit9bccdc3dd3c473b6748cb5a93be7346c5c824cd4 (patch)
tree3a718702cd530a1a864d5744f2e34515d81f3adf /src
parent3ad06f7dc738940ee31a21e3b95c0f3d3b8dbd6f (diff)
downloadstasis-9bccdc3dd3c473b6748cb5a93be7346c5c824cd4.tar.gz
handle asprintf errors
Diffstat (limited to 'src')
-rw-r--r--src/cli/stasis_indexer/helpers.c5
-rw-r--r--src/cli/stasis_indexer/readmes.c5
-rw-r--r--src/lib/core/utils.c10
3 files changed, 14 insertions, 6 deletions
diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c
index 425d209..9304fcc 100644
--- a/src/cli/stasis_indexer/helpers.c
+++ b/src/cli/stasis_indexer/helpers.c
@@ -295,7 +295,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("%s", "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 7357fca..f5243bb 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("%s", "Unable to allocate bytes for pattern");
fclose(indexfp);
return -1;
diff --git a/src/lib/core/utils.c b/src/lib/core/utils.c
index f8fcadb..b4fd726 100644
--- a/src/lib/core/utils.c
+++ b/src/lib/core/utils.c
@@ -893,9 +893,15 @@ int env_manipulate_pathstr(const char *key, char *path, int mode) {
char *system_path_new = NULL;
if (mode & PM_APPEND) {
- asprintf(&system_path_new, "%s%s%s", system_path_old, PATH_SEP, path);
+ if (asprintf(&system_path_new, "%s%s%s", system_path_old, PATH_SEP, path) < 0 || !system_path_new) {
+ SYSERROR("%s", "Unable to allocate memory to update PATH");
+ return -1;
+ }
} else if (mode & PM_PREPEND) {
- asprintf(&system_path_new, "%s%s%s", path, PATH_SEP, system_path_old);
+ if (asprintf(&system_path_new, "%s%s%s", path, PATH_SEP, system_path_old) < 0 || !system_path_new) {
+ SYSERROR("%s", "Unable to allocate memory to update PATH");
+ return -1;
+ }
}
if (!system_path_new) {