From a9f3ed63573693836d7bab50403c23fb5bf75507 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 7 May 2026 14:58:58 -0400 Subject: Replace BUFSIZ with STASIS_BUFSIZ --- src/lib/core/conda.c | 2 +- src/lib/core/ini.c | 7 +++++-- src/lib/core/multiprocessing.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/lib') diff --git a/src/lib/core/conda.c b/src/lib/core/conda.c index b5f0f77..4597128 100644 --- a/src/lib/core/conda.c +++ b/src/lib/core/conda.c @@ -230,7 +230,7 @@ int pkg_index_provides(int mode, const char *index, const char *spec, const char remove(logfile); return -1; } else { - char line[BUFSIZ] = {0}; + char line[STASIS_BUFSIZ] = {0}; fflush(stdout); fflush(stderr); while (fgets(line, sizeof(line) - 1, fp) != NULL) { diff --git a/src/lib/core/ini.c b/src/lib/core/ini.c index c37030c..ea8c0dd 100644 --- a/src/lib/core/ini.c +++ b/src/lib/core/ini.c @@ -180,6 +180,8 @@ int ini_getval(struct INIFILE *ini, char *section_name, char *key, int type, int } break; case INIVAL_TYPE_STR_ARRAY: + // TODO: data_copy should be at least equal to the length of the data. The use of STASIS_BUFSIZ below is + // the root cause of crashes when stasis reads long arrays. strncpy(tbufp, data_copy, sizeof(tbuf) - 1); tbuf[sizeof(tbuf) - 1] = '\0'; guard_free(data_copy); @@ -191,10 +193,11 @@ int ini_getval(struct INIFILE *ini, char *section_name, char *key, int type, int while ((token = strsep(&tbufp, "\n")) != NULL) { //lstrip(token); if (!isempty(token)) { - strncat(data_copy, token, BUFSIZ - strlen(data_copy) - 1); - strncat(data_copy, "\n", BUFSIZ - strlen(data_copy) - 1); + strncat(data_copy, token, STASIS_BUFSIZ - strlen(data_copy) - 1); + strncat(data_copy, "\n", STASIS_BUFSIZ - strlen(data_copy) - 1); } } + data_copy[STASIS_BUFSIZ - 1] = '\0'; strip(data_copy); result->as_char_p = strdup(data_copy); break; diff --git a/src/lib/core/multiprocessing.c b/src/lib/core/multiprocessing.c index 8fd8b93..cf0f3d7 100644 --- a/src/lib/core/multiprocessing.c +++ b/src/lib/core/multiprocessing.c @@ -270,7 +270,7 @@ static int show_log_contents(FILE *stream, struct MultiProcessingTask *task) { if (!fp) { return -1; } - char buf[BUFSIZ] = {0}; + char buf[STASIS_BUFSIZ] = {0}; while ((fgets(buf, sizeof(buf) - 1, fp)) != NULL) { fprintf(stream, "%s", buf); memset(buf, 0, sizeof(buf)); -- cgit From 9468c81718046af0a0b32c492bee359a98e2e8e9 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 7 May 2026 15:35:23 -0400 Subject: Create XDG_CONFIG_HOME and XDG_CACHE_HOME directories --- src/lib/delivery/delivery_init.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/lib') diff --git a/src/lib/delivery/delivery_init.c b/src/lib/delivery/delivery_init.c index ec05a0f..024815b 100644 --- a/src/lib/delivery/delivery_init.c +++ b/src/lib/delivery/delivery_init.c @@ -294,10 +294,18 @@ int delivery_init(struct Delivery *ctx, int render_mode) { char config_local[PATH_MAX]; snprintf(config_local, sizeof(config_local), "%s/%s", ctx->storage.tmpdir, "config"); setenv("XDG_CONFIG_HOME", config_local, 1); + if (mkdirs(config_local, 0755)) { + SYSERROR("%s: unable to create directory", config_local); + // fall through because XDG doesn't _really_ need to be there + } char cache_local[PATH_MAX]; snprintf(cache_local, sizeof(cache_local), "%s/%s", ctx->storage.tmpdir, "cache"); setenv("XDG_CACHE_HOME", cache_local, 1); + if (mkdirs(cache_local, 0755)) { + SYSERROR("%s: unable to create directory", cache_local); + // fall through because XDG doesn't _really_ need to be there + } // add tools to PATH char pathvar_tmp[STASIS_BUFSIZ]; -- cgit