diff --git a/src/cmsg.c b/src/cmsg.c index a8ff29a9..72003530 100644 --- a/src/cmsg.c +++ b/src/cmsg.c @@ -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}; } diff --git a/src/ctrl.c b/src/ctrl.c index 56b7f397..ced9886b 100644 --- a/src/ctrl.c +++ b/src/ctrl.c @@ -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); diff --git a/src/seccomp_notify.c b/src/seccomp_notify.c index bbc06ddb..9154f820 100644 --- a/src/seccomp_notify.c +++ b/src/seccomp_notify.c @@ -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");