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 | |
| parent | e412ae6ff1aa793799ccdbe893484273e71e909a (diff) | |
| download | stasis-a9f3ed63573693836d7bab50403c23fb5bf75507.tar.gz | |
Replace BUFSIZ with STASIS_BUFSIZ
| -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-- | tests/test_download.c | 2 | ||||
| -rw-r--r-- | tests/test_environment.c | 2 | ||||
| -rw-r--r-- | tests/test_relocation.c | 4 | ||||
| -rw-r--r-- | tests/test_utils.c | 2 |
7 files changed, 12 insertions, 9 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/tests/test_download.c b/tests/test_download.c index 31e9792..6ace119 100644 --- a/tests/test_download.c +++ b/tests/test_download.c @@ -21,7 +21,7 @@ void test_download() { for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) { const char *filename = "output.txt"; - char errmsg[BUFSIZ] = {0}; + char errmsg[STASIS_BUFSIZ] = {0}; char *errmsg_p = errmsg; long http_code = download((char *) tc[i].url, filename, &errmsg_p); if (tc[i].errmsg) { diff --git a/tests/test_environment.c b/tests/test_environment.c index 9a503c0..72a938d 100644 --- a/tests/test_environment.c +++ b/tests/test_environment.c @@ -56,7 +56,7 @@ void test_runtime() { STASIS_ASSERT(strcmp(global_custom_value, custom_value) == 0, "local and global CUSTOM_KEY variable are supposed to be identical"); guard_free(custom_value); - char output_truth[BUFSIZ] = {0}; + char output_truth[STASIS_BUFSIZ] = {0}; char *your_path = runtime_get(env, "PATH"); snprintf(output_truth, sizeof(output_truth), "Your PATH is '%s'.", your_path); guard_free(your_path); diff --git a/tests/test_relocation.c b/tests/test_relocation.c index 4a02e01..891e346 100644 --- a/tests/test_relocation.c +++ b/tests/test_relocation.c @@ -13,7 +13,7 @@ void test_replace_text() { for (size_t i = 0; i < sizeof(targets) / sizeof(*targets); i += 2) { const char *target = targets[i]; const char *expected = targets[i + 1]; - char input[BUFSIZ] = {0}; + char input[STASIS_BUFSIZ] = {0}; strncpy(input, test_string, sizeof(input) - 1); input[sizeof(input) - 1] = '\0'; @@ -44,7 +44,7 @@ void test_file_replace_text() { return; } - char input[BUFSIZ] = {0}; + char input[STASIS_BUFSIZ] = {0}; fp = fopen(filename, "r"); if (fp) { fread(input, sizeof(*input), sizeof(input), fp); diff --git a/tests/test_utils.c b/tests/test_utils.c index fd398e2..119dea3 100644 --- a/tests/test_utils.c +++ b/tests/test_utils.c @@ -105,7 +105,7 @@ void test_xml_pretty_print_in_place() { } fp = fopen(filename, "r"); - char buf[BUFSIZ] = {0}; + char buf[STASIS_BUFSIZ] = {0}; if (fread(buf, sizeof(*buf), sizeof(buf) - 1, fp) < 1) { STASIS_ASSERT(false, "failed to consume formatted xml file contents"); } |
