Skip to content
Merged

Fix BOF #1851

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion contrib/seccomp-receiver/seccomp-receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ open_unix_domain_socket (const char *path)
int fd = socket (AF_UNIX, SOCK_STREAM, 0);
if (fd < 0)
error (EXIT_FAILURE, errno, "error creating UNIX socket");


if (strlen (path) >= sizeof (addr.sun_path))
error (EXIT_FAILURE, 0, "invalid path");
Comment on lines +51 to +52
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: The error message for an invalid path could be more descriptive.

Consider adding the invalid path or its length to the error message for better debugging context.

Suggested change
if (strlen (path) >= sizeof (addr.sun_path))
error (EXIT_FAILURE, 0, "invalid path");
if (strlen (path) >= sizeof (addr.sun_path))
error (EXIT_FAILURE, 0, "invalid path: '%s' (length: %zu, max: %zu)", path, strlen(path), sizeof(addr.sun_path) - 1);


strcpy (addr.sun_path, path);
addr.sun_family = AF_UNIX;
ret = bind (fd, (struct sockaddr *) &addr, sizeof (addr));
Expand Down