Skip to content

Commit

Permalink
drivers/usbdev/cdcacm.c: Set reqlen properly according to ep->maxpack…
Browse files Browse the repository at this point in the history
…et and CONFIG_CDCACM_BULKIN_REQLEN

The request length may not exceed CONFIG_CDCACM_BULKIN_REQLEN, otherwise buffer overflow will occur

Signed-off-by: Jukka Laitinen <[email protected]>
  • Loading branch information
jlaitine committed Oct 2, 2024
1 parent 50ba308 commit e6bd303
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/usbdev/cdcacm.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv)

/* Get the maximum number of bytes that will fit into one bulk IN request */

reqlen = MAX(CONFIG_CDCACM_BULKIN_REQLEN, ep->maxpacket);
reqlen = ep->maxpacket > CONFIG_CDCACM_BULKIN_REQLEN ?
CONFIG_CDCACM_BULKIN_REQLEN : ep->maxpacket;

while (!sq_empty(&priv->txfree))
{
Expand Down

0 comments on commit e6bd303

Please sign in to comment.