aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2026-06-02 17:04:13 -0400
committerGitHub <noreply@github.com>2026-06-02 17:04:13 -0400
commit252b9646c1cb0538123d51ced4a733f3dcfc266b (patch)
tree84b300af068db367bd9f3262487aeef3c7ba22d0 /tests
parentd8ee8c27444a56bb98dd8bd67a019a1e9efbcc10 (diff)
downloadstasis-252b9646c1cb0538123d51ced4a733f3dcfc266b.tar.gz
Safe strings, finally (#145)
* Add string copy and catonate replacements * safe_strncpy * safe_strncat * Replace string functions * gbo.ini: Update tweakwcs to 0.9.0 * generic.ini: Update tweakwcs to 0.9.0
Diffstat (limited to 'tests')
-rw-r--r--tests/data/gbo.ini2
-rw-r--r--tests/data/generic.ini2
-rw-r--r--tests/test_relocation.c3
-rw-r--r--tests/test_utils.c7
4 files changed, 6 insertions, 8 deletions
diff --git a/tests/data/gbo.ini b/tests/data/gbo.ini
index 3ee6481..430246a 100644
--- a/tests/data/gbo.ini
+++ b/tests/data/gbo.ini
@@ -18,7 +18,7 @@ installer_baseurl = https://github.com/conda-forge/miniforge/releases/download/{
pip_packages =
firewatch==0.0.4
gwcs==0.22.1
- tweakwcs==0.8.8
+ tweakwcs==0.9.0
[runtime]
diff --git a/tests/data/generic.ini b/tests/data/generic.ini
index 5e07ed2..3d9c513 100644
--- a/tests/data/generic.ini
+++ b/tests/data/generic.ini
@@ -18,7 +18,7 @@ installer_baseurl = https://github.com/conda-forge/miniforge/releases/download/{
pip_packages =
firewatch==0.0.4
gwcs==0.22.1
- tweakwcs==0.8.8
+ tweakwcs==0.9.0
[runtime]
diff --git a/tests/test_relocation.c b/tests/test_relocation.c
index 891e346..8a6bc49 100644
--- a/tests/test_relocation.c
+++ b/tests/test_relocation.c
@@ -14,8 +14,7 @@ void test_replace_text() {
const char *target = targets[i];
const char *expected = targets[i + 1];
char input[STASIS_BUFSIZ] = {0};
- strncpy(input, test_string, sizeof(input) - 1);
- input[sizeof(input) - 1] = '\0';
+ safe_strncpy(input, test_string, sizeof(input));
printf("input: %s\n", input);
printf("target: %s\n", target);
diff --git a/tests/test_utils.c b/tests/test_utils.c
index 696e7ff..fc53f53 100644
--- a/tests/test_utils.c
+++ b/tests/test_utils.c
@@ -313,8 +313,7 @@ void test_path_dirname() {
const char *input = data[i];
const char *expected = data[i + 1];
char tmp[PATH_MAX] = {0};
- strncpy(tmp, input, sizeof(tmp) - 1);
- tmp[sizeof(tmp) - 1] = '\0';
+ safe_strncpy(tmp, input, sizeof(tmp));
char *result = path_dirname(tmp);
STASIS_ASSERT(strcmp(expected, result) == 0, NULL);
@@ -349,8 +348,8 @@ void test_expandpath() {
STASIS_ASSERT_FATAL(home != NULL, "cannot expand without knowing the user's home directory path");
char path[PATH_MAX] = {0};
- strncat(path, "~", sizeof(path) - strlen(path) - 1);
- strncat(path, DIR_SEP, sizeof(path) - strlen(path) - 1);
+ safe_strncat(path, "~", sizeof(path));
+ safe_strncat(path, DIR_SEP, sizeof(path));
char *expanded = expandpath(path);
STASIS_ASSERT(startswith(expanded, home) > 0, expanded);