acassis commented on code in PR #19000:
URL: https://github.com/apache/nuttx/pull/19000#discussion_r3334298357


##########
arch/sim/src/sim/sim_usrsock.c:
##########
@@ -357,15 +357,28 @@ 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))
+    {
+      return -EINVAL;

Review Comment:
   @Zepp-Hanzj I think a proper nerr() message should be added to explain the 
error to users trying to use it.



##########
arch/sim/src/sim/sim_usrsock.c:
##########
@@ -357,15 +357,28 @@ 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))
+    {
+      return -EINVAL;
+    }
+
+  copylen = req->arglen;
+  if (copylen > len - sizeof(*req) ||
+      copylen > SIM_USRSOCK_BUFSIZE - sizeof(*ack))
+    {
+      return -EINVAL;

Review Comment:
   Ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to