From 24961e9d228531f1cb60739239d7591aa70bdd53 Mon Sep 17 00:00:00 2001 From: Martin George Date: Fri, 29 Nov 2024 11:04:34 +0530 Subject: [PATCH] netapp-ontapdev: fix fw version handling The string used to capture the fw version was not handled properly. Fix the same. Signed-off-by: Martin George --- plugins/netapp/netapp-nvme.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/netapp/netapp-nvme.c b/plugins/netapp/netapp-nvme.c index cebd019e..76e8ddf1 100644 --- a/plugins/netapp/netapp-nvme.c +++ b/plugins/netapp/netapp-nvme.c @@ -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; -- 2.43.5