Skip to content

Commit 7d6ceeb

Browse files
Mirsad Goran Todorovacdavem330
authored andcommitted
af_unix: selftest: Fix the size of the parameter to connect()
Adjust size parameter in connect() to match the type of the parameter, to fix "No such file or directory" error in selftests/net/af_unix/ test_oob_unix.c:127. The existing code happens to work provided that the autogenerated pathname is shorter than sizeof (struct sockaddr), which is why it hasn't been noticed earlier. Visible from the trace excerpt: bind(3, {sa_family=AF_UNIX, sun_path="unix_oob_453059"}, 110) = 0 clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fa6a6577a10) = 453060 [pid <child>] connect(6, {sa_family=AF_UNIX, sun_path="unix_oob_45305"}, 16) = -1 ENOENT (No such file or directory) BUG: The filename is trimmed to sizeof (struct sockaddr). Cc: "David S. Miller" <[email protected]> Cc: Eric Dumazet <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: Paolo Abeni <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Kuniyuki Iwashima <[email protected]> Cc: Florian Westphal <[email protected]> Reviewed-by: Florian Westphal <[email protected]> Fixes: 314001f ("af_unix: Add OOB support") Signed-off-by: Mirsad Goran Todorovac <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 76761ba commit 7d6ceeb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/net/af_unix/test_unix_oob.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ void producer(struct sockaddr_un *consumer_addr)
124124

125125
wait_for_signal(pipefd[0]);
126126
if (connect(cfd, (struct sockaddr *)consumer_addr,
127-
sizeof(struct sockaddr)) != 0) {
127+
sizeof(*consumer_addr)) != 0) {
128128
perror("Connect failed");
129129
kill(0, SIGTERM);
130130
exit(1);

0 commit comments

Comments
 (0)