Skip to content

Commit

Permalink
fabrics: fix potential invalid memory access in __nvmf_supported_opti…
Browse files Browse the repository at this point in the history
…on()

In __nvmf_supported_option(), len is declared as size_t (unsigned)

"len = read()" may return a negative number;
the check "if (len < 0)" will always be false and therefore
"buf[len]" will dereference an invalid memory address.

len should be declared as a signed size_t (ssize_t)

Signed-off-by: Maurizio Lombardi <[email protected]>
  • Loading branch information
maurizio-lombardi authored and igaw committed May 8, 2023
1 parent 2aaf2ed commit f7ba8bf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/nvme/fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ static int __nvmf_supported_options(nvme_root_t r)
{
char buf[0x1000], *options, *p, *v;
int fd, ret;
size_t len;
ssize_t len;

if (r->options)
return 0;
Expand Down

0 comments on commit f7ba8bf

Please sign in to comment.