Skip to content

Commit

Permalink
sealed-fd: Check that the supplied FD index is in the UnixFDList
Browse files Browse the repository at this point in the history
The index is user provided and can be basically any number so we have to
make sure it corresponds with an FD send out of band, collected in the
UnixFDList.
  • Loading branch information
swick authored and GeorgesStavracas committed Nov 5, 2024
1 parent bfb1c08 commit 4a2abe2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/xdp-sealed-fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,15 @@ xdp_sealed_fd_new_from_handle (GVariant *handle,

g_return_val_if_fail (g_variant_is_of_type (handle, G_VARIANT_TYPE_HANDLE), NULL);
g_return_val_if_fail (G_IS_UNIX_FD_LIST (fd_list), NULL);
g_return_val_if_fail (g_unix_fd_list_get_length (fd_list) > 0, NULL);

fd_id = g_variant_get_handle (handle);
if (fd_id >= g_unix_fd_list_get_length (fd_list))
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
"Invalid file descriptor: index not found");
return NULL;
}

fd = g_unix_fd_list_get (fd_list, fd_id, error);
if (fd == -1)
return NULL;
Expand Down

0 comments on commit 4a2abe2

Please sign in to comment.