diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-16 11:52:11 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-16 11:52:11 -0400 |
| commit | dc6b871b419159097c272fe21cdef6acece40a99 (patch) | |
| tree | 1d2e4ef745106cb4a7a804698b45739a163cbe38 /tests | |
| parent | f40adf8259a9f034b6fff7abff047e9a746f7ec1 (diff) | |
| download | stasis-dc6b871b419159097c272fe21cdef6acece40a99.tar.gz | |
Convert more strcat and strcpy to strn variants
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_utils.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/test_utils.c b/tests/test_utils.c index 5766f6c..1ad2335 100644 --- a/tests/test_utils.c +++ b/tests/test_utils.c @@ -329,8 +329,7 @@ void test_path_basename() { } void test_expandpath() { - char *home; - + char *home = NULL; const char *homes[] = { "HOME", "USERPROFILE", @@ -341,10 +340,11 @@ void test_expandpath() { break; } } + STASIS_ASSERT_FATAL(home != NULL, "cannot expand without knowing the user's home directory path"); char path[PATH_MAX] = {0}; - strcat(path, "~"); - strcat(path, DIR_SEP); + strncat(path, "~", sizeof(path) - strlen(path) - 1); + strncat(path, DIR_SEP, sizeof(path) - strlen(path) - 1); char *expanded = expandpath(path); STASIS_ASSERT(startswith(expanded, home) > 0, expanded); |
