Skip to content

Commit

Permalink
cmsg: recvfd returns an error on failures
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Apr 27, 2023
1 parent 76f10b4 commit 97e431f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,5 @@ struct file_t recvfd(int sockfd)
olderrno = errno;
free(file.name);
errno = olderrno;
return (struct file_t){0};
return (struct file_t){.name = NULL, .fd = -1};
}
5 changes: 5 additions & 0 deletions src/ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ gboolean terminal_accept_cb(int fd, G_GNUC_UNUSED GIOCondition condition, G_GNUC
ndebugf("about to recvfd from connfd: %d", connfd);
struct file_t console = recvfd(connfd);

if (console.fd < 0) {
nwarn("Failed to receive console file descriptor");
goto exit;
}

ndebugf("console = {.name = '%s'; .fd = %d}", console.name, console.fd);
free(console.name);

Expand Down
5 changes: 5 additions & 0 deletions src/seccomp_notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ gboolean seccomp_accept_cb(int fd, G_GNUC_UNUSED GIOCondition condition, G_GNUC_
struct file_t listener = recvfd(connfd);
close(connfd);

if (listener.fd < 0) {
nwarn("Failed to receive socket listener file descriptor");
return G_SOURCE_CONTINUE;
}

_cleanup_free_ char *oci_config_path = g_strdup_printf("%s/config.json", opt_bundle_path);
if (oci_config_path == NULL) {
nwarn("Failed to allocate memory");
Expand Down

0 comments on commit 97e431f

Please sign in to comment.