diff options
author | Sean Anderson <seanga2@gmail.com> | 2022-03-23 18:24:38 -0400 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2022-06-28 03:09:51 +0100 |
commit | 24057fe0a8f70ae872da0a8f4889fe7b8cfa09db (patch) | |
tree | d6f7949dca9f791d2ccca12cc2927822dfe295d2 /drivers/core/devres.c | |
parent | 42ae363ddd99c38ab26434b9d1c8b68610844e79 (diff) |
sandbox: usb: Fix out-of-bounds read when fd=-1
sandbox_flash_bulk uses priv->read_len to determine if priv->buff contains
the response data (such as from SCSI_INQUIRY). However, if priv->fd=-1 in
handle_read, then priv->read_len is not set even though we are going to
PHASE_DATA. This causes sandbox_flash_bulk to try and read len bytes from
priv->buff, which likely goes past the end of the buffer. Fix this by always
setting priv->read_len even if we aren't going to read anything.
Fixes: f4f715360c ("dm: usb: sandbox: Add an emulator for USB flash devices")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core/devres.c')
0 files changed, 0 insertions, 0 deletions