diff --git a/test/unistd/test_unistd_write_broken_link.c b/test/unistd/test_unistd_write_broken_link.c index 1c119a6e45a7e..014af7860b78f 100644 --- a/test/unistd/test_unistd_write_broken_link.c +++ b/test/unistd/test_unistd_write_broken_link.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -16,7 +17,9 @@ int main() { int target_fd = open("link_target", O_RDONLY); printf("target_fd: %d, errno: %d %s\n", target_fd, errno, strerror(errno)); char buf[10]; - read(target_fd, buf, 10); + memset(buf, 0, 10); + size_t r = read(target_fd, buf, 10); + assert(r == 3); printf("buf: '%s'\n", buf); close(target_fd); } @@ -24,7 +27,9 @@ int main() { int target_fd = open("link_source", O_RDONLY); printf("target_fd: %d, errno: %d %s\n", target_fd, errno, strerror(errno)); char buf[10]; - read(target_fd, buf, 10); + memset(buf, 0, 10); + size_t r = read(target_fd, buf, 10); + assert(r == 3); printf("buf: '%s'\n", buf); close(target_fd); }