summaryrefslogtreecommitdiff
path: root/test/test_syscalls.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_syscalls.c')
-rw-r--r--test/test_syscalls.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/test/test_syscalls.c b/test/test_syscalls.c
index 65292ed..c835661 100644
--- a/test/test_syscalls.c
+++ b/test/test_syscalls.c
@@ -1868,9 +1868,10 @@ static int test_socket(void)
int fd;
int res;
int err = 0;
+ const size_t test_sock_len = strlen(testsock) + 1;
start_test("socket");
- if (strlen(testsock) + 1 > sizeof(su.sun_path)) {
+ if (test_sock_len > sizeof(su.sun_path)) {
fprintf(stderr, "Need to shorten mount point by %zu chars\n",
strlen(testsock) + 1 - sizeof(su.sun_path));
return -1;
@@ -1882,7 +1883,8 @@ static int test_socket(void)
return -1;
}
su.sun_family = AF_UNIX;
- strncpy(su.sun_path, testsock, sizeof(su.sun_path) - 1);
+
+ strncpy(su.sun_path, testsock, test_sock_len);
su.sun_path[sizeof(su.sun_path) - 1] = '\0';
res = bind(fd, (struct sockaddr*)&su, sizeof(su));
if (res == -1) {