Skip to content

Commit 9b2ce6c

Browse files
saargross-amazonkeithbusch
authored andcommitted
nvme-print: fix offset calculation in NS ID Descriptor list
The offset for the next entry in the list is based on the length (len) of the previous entry, but len is erroneously accumulated instead of being set. This works fine for the first and second entry in the list but will fail to reach the correct offset for the 3rd entry and beyond. Signed-off-by: Saar Gross <[email protected]>
1 parent 0f46375 commit 9b2ce6c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

nvme-print.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,23 +2537,23 @@ static void json_nvme_id_ns_descs(void *data)
25372537
memcpy(desc.eui64, data + off, sizeof(desc.eui64));
25382538
for (i = 0; i < sizeof(desc.eui64); i++)
25392539
json_str_p += sprintf(json_str_p, "%02x", desc.eui64[i]);
2540-
len += sizeof(desc.eui64);
2540+
len = sizeof(desc.eui64);
25412541
nidt_name = "eui64";
25422542
break;
25432543

25442544
case NVME_NIDT_NGUID:
25452545
memcpy(desc.nguid, data + off, sizeof(desc.nguid));
25462546
for (i = 0; i < sizeof(desc.nguid); i++)
25472547
json_str_p += sprintf(json_str_p, "%02x", desc.nguid[i]);
2548-
len += sizeof(desc.nguid);
2548+
len = sizeof(desc.nguid);
25492549
nidt_name = "nguid";
25502550
break;
25512551

25522552
#ifdef LIBUUID
25532553
case NVME_NIDT_UUID:
25542554
memcpy(desc.uuid, data + off, sizeof(desc.uuid));
25552555
uuid_unparse_lower(desc.uuid, json_str);
2556-
len += sizeof(desc.uuid);
2556+
len = sizeof(desc.uuid);
25572557
nidt_name = "uuid";
25582558
break;
25592559
#endif

0 commit comments

Comments
 (0)