Skip to content

Commit

Permalink
Fix: Array bounds read in zprop_print_one_property()
Browse files Browse the repository at this point in the history
If the loop index i comes to (ZFS_GET_NCOLS - 1), the cbp->cb_columns[i + 1]
actually read the data of cbp->cb_colwidths[0], which means the array
subscript is above array bounds.

Luckily the cbp->cb_colwidths[0] is always 0 and it seems we haven't
looped enough times to exceed the array bounds so far, but it's really
a secluded risk someday.

Signed-off-by: GeLiXin <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #5003
  • Loading branch information
GeLiXin authored and behlendorf committed Aug 22, 2016
1 parent 9cc1844 commit 23827a4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/libzfs/libzfs_util.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,8 @@ zprop_print_one_property(const char *name, zprop_get_cbdata_t *cbp,
continue;
}

if (cbp->cb_columns[i + 1] == GET_COL_NONE)
if (i == (ZFS_GET_NCOLS - 1) ||
cbp->cb_columns[i + 1] == GET_COL_NONE)
(void) printf("%s", str);
else if (cbp->cb_scripted)
(void) printf("%s\t", str);
Expand Down

0 comments on commit 23827a4

Please sign in to comment.