Skip to content

Commit 2ab5593

Browse files
Added fix for zpool get state segfaults with two or more vdevs (openzfs#15972).
The problem was identified in handling of the zpool get state command line arguments. A pointer vdev was used to point to the argv[1], and its address set to cb.cb_vdevs.cb_names(pointer to array of strings) so any increment to cb_names resulted in a segfault. Fix covers a special case of root parameter at argv[1] and remaining cases are handled by passing in the argv + 1, which allows cb_names iteration of next command line arguments (vdevs). Signed-off-by: Syed Shahrukh Hussain <[email protected]>
1 parent 7be9fa2 commit 2ab5593

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cmd/zpool/zpool_main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12747,11 +12747,13 @@ zpool_do_get(int argc, char **argv)
1274712747

1274812748
if (strcmp(argv[1], "root") == 0)
1274912749
vdev = strdup("root-0");
12750-
else
12751-
vdev = strdup(argv[1]);
1275212750

1275312751
/* ... and the rest are vdev names */
12754-
cb.cb_vdevs.cb_names = &vdev;
12752+
if (vdev == NULL)
12753+
cb.cb_vdevs.cb_names = argv + 1;
12754+
else
12755+
cb.cb_vdevs.cb_names = &vdev;
12756+
1275512757
cb.cb_vdevs.cb_names_count = argc - 1;
1275612758
cb.cb_type = ZFS_TYPE_VDEV;
1275712759
argc = 1; /* One pool to process */

0 commit comments

Comments
 (0)