]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
ns_descs: prevent buffer overrun and memory corruption
authorMaurizio Lombardi <mlombard@redhat.com>
Fri, 6 Dec 2024 13:17:06 +0000 (14:17 +0100)
committerDaniel Wagner <wagi@monom.org>
Fri, 6 Dec 2024 13:51:59 +0000 (14:51 +0100)
nsdescs should point to an allocated memory of size
NVME_IDENTIFY_DATA_SIZE bytes, not "sizeof(*void)" bytes.

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
nvme.c

diff --git a/nvme.c b/nvme.c
index 4db3cd638a0477de3007987dadc7cb654aa6b83e..16acaf9fb7d9e47dad50300785162ce5ff94d4a4 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -3700,7 +3700,7 @@ static int ns_descs(int argc, char **argv, struct command *cmd, struct plugin *p
                }
        }
 
-       nsdescs = nvme_alloc(sizeof(*nsdescs));
+       nsdescs = nvme_alloc(NVME_IDENTIFY_DATA_SIZE);
        if (!nsdescs)
                return -ENOMEM;