Skip to content
Open
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
22 changes: 20 additions & 2 deletions arch/sim/src/sim/sim_usrsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <string.h>

#include <nuttx/arch.h>
#include <nuttx/debug.h>
#include <nuttx/net/usrsock.h>
#include <nuttx/wqueue.h>

Expand Down Expand Up @@ -357,15 +358,32 @@ static int usrsock_ioctl_handler(struct usrsock_s *usrsock,
{
const struct usrsock_request_ioctl_s *req = data;
struct usrsock_message_datareq_ack_s *ack;
size_t copylen;
int ret;

if (len < sizeof(*req))
{
nerr("ERROR: ioctl request too short: %zu < %zu\n",
len, sizeof(*req));
return -EINVAL;
Comment thread
acassis marked this conversation as resolved.
}

copylen = req->arglen;
if (copylen > len - sizeof(*req) ||
copylen > SIM_USRSOCK_BUFSIZE - sizeof(*ack))
{
nerr("ERROR: ioctl arglen invalid: %zu (len=%zu bufsize=%zu)\n",
copylen, len, (size_t)SIM_USRSOCK_BUFSIZE);
return -EINVAL;
Comment thread
acassis marked this conversation as resolved.
}

ack = (struct usrsock_message_datareq_ack_s *)usrsock->out;
memcpy(ack + 1, req + 1, req->arglen);
memcpy(ack + 1, req + 1, copylen);
ret = host_usrsock_ioctl(req->usockid, req->cmd,
(unsigned long)(ack + 1));

return usrsock_send_dack(usrsock, ack, req->head.xid, ret,
req->arglen, req->arglen);
copylen, copylen);
}

static int usrsock_shutdown_handler(struct usrsock_s *usrsock,
Expand Down