summaryrefslogtreecommitdiffstats
path: root/test/test_filesystem.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_filesystem.c')
-rw-r--r--test/test_filesystem.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/test/test_filesystem.c b/test/test_filesystem.c
index 4a1ad4f..e6180fb 100644
--- a/test/test_filesystem.c
+++ b/test/test_filesystem.c
@@ -162,15 +162,17 @@ test_file_type(void)
const socklen_t addr_len = sizeof(struct sockaddr_un);
struct sockaddr_un* const addr = (struct sockaddr_un*)calloc(1, addr_len);
- addr->sun_family = AF_UNIX;
- strncpy(addr->sun_path, file_path, sizeof(addr->sun_path) - 1);
-
- const int fd = bind(sock, (struct sockaddr*)addr, addr_len);
- if (fd >= 0) {
- assert(zix_file_type(file_path) == ZIX_FILE_TYPE_SOCKET);
- assert(!zix_remove(file_path));
- close(fd);
- }
+ if (strlen(file_path) < sizeof(addr->sun_path)) {
+ addr->sun_family = AF_UNIX;
+ strncpy(addr->sun_path, file_path, sizeof(addr->sun_path) - 1);
+
+ const int fd = bind(sock, (struct sockaddr*)addr, addr_len);
+ if (fd >= 0) {
+ assert(zix_file_type(file_path) == ZIX_FILE_TYPE_SOCKET);
+ assert(!zix_remove(file_path));
+ close(fd);
+ }
+ } // otherwise, TMPDIR is oddly long, skip test
close(sock);
free(addr);