diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-05-07 14:58:58 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-05-07 15:00:16 -0400 |
| commit | a9f3ed63573693836d7bab50403c23fb5bf75507 (patch) | |
| tree | 372092edc26b5f6d546f003bfa14aea78a531cfe /src | |
| parent | e412ae6ff1aa793799ccdbe893484273e71e909a (diff) | |
| download | stasis-a9f3ed63573693836d7bab50403c23fb5bf75507.tar.gz | |
Replace BUFSIZ with STASIS_BUFSIZ
Diffstat (limited to 'src')
| -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 |
3 files changed, 7 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)); |
