diff options
| author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2026-05-07 15:54:00 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-07 15:54:00 -0400 |
| commit | 0ef06cbec6f3796db244501b4c5fec2d579c7e5b (patch) | |
| tree | 675651a16986ebfc1473102d9ce6d7187fc107d0 /src/lib | |
| parent | b494ddd036f9b17fcfabd42decd325bbe8be914e (diff) | |
| parent | 9468c81718046af0a0b32c492bee359a98e2e8e9 (diff) | |
| download | stasis-0ef06cbec6f3796db244501b4c5fec2d579c7e5b.tar.gz | |
Merge pull request #141 from jhunkeler/use-stasis-bufsiz
Replace BUFSIZ with STASIS_BUFSIZ
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/core/conda.c | 2 | ||||
| -rw-r--r-- | src/lib/core/ini.c | 7 | ||||
| -rw-r--r-- | src/lib/core/multiprocessing.c | 2 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_init.c | 8 |
4 files changed, 15 insertions, 4 deletions
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)); 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]; |
