]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
netapp-ontapdev: fix fw version handling
authorMartin George <marting@netapp.com>
Fri, 29 Nov 2024 05:34:34 +0000 (11:04 +0530)
committerDaniel Wagner <wagi@monom.org>
Mon, 2 Dec 2024 14:02:14 +0000 (15:02 +0100)
The string used to capture the fw version was not handled
properly. Fix the same.

Signed-off-by: Martin George <marting@netapp.com>
plugins/netapp/netapp-nvme.c

index cebd019e9da6db332b06165c728d6227904a3f89..76e8ddf196bc59aa028da9ea066fda683bcabac3 100644 (file)
@@ -146,10 +146,11 @@ static void netapp_get_ns_attrs(char *size, char *used, char *blk_size,
 
        sprintf(blk_size, "%u%sB", (unsigned int)addr, l_suffix);
 
-       /* get the ontap version */
+       /* get the firmware version */
        int i, max = sizeof(ctrl->fr);
 
-       memcpy(version, ctrl->fr, sizeof(ctrl->fr));
+       memcpy(version, ctrl->fr, max);
+       version[max] = '\0';
        /* strip trailing whitespaces */
        for (i = max - 1; i >= 0 && version[i] == ' '; i--)
                version[i] = '\0';
@@ -455,7 +456,7 @@ static void netapp_ontapdevices_print_verbose(struct ontapdevice_info *devices,
        char nspath[ONTAP_NS_PATHLEN] = " ";
        unsigned long long lba;
        char size[128], used[128];
-       char blk_size[128], version[8];
+       char blk_size[128], version[9];
        char uuid_str[37] = " ";
        int i;
 
@@ -571,7 +572,7 @@ static void netapp_ontapdevices_print_json(struct ontapdevice_info *devices,
        char nspath[ONTAP_NS_PATHLEN] = " ";
        unsigned long long lba;
        char size[128], used[128];
-       char blk_size[128], version[8];
+       char blk_size[128], version[9];
        char uuid_str[37] = " ";
        int i;