aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzfs/libzfs_util.c
diff options
context:
space:
mode:
authorChrister Ekholm <[email protected]>2015-02-19 22:44:53 +0100
committerBrian Behlendorf <[email protected]>2015-02-24 11:39:10 -0800
commit8bdcfb53966313e9ff747e3028390c207cfdbe9a (patch)
treeac366d3eebaf850386d639c57381e439135c242c /lib/libzfs/libzfs_util.c
parentb4f3666a16a61aa2ac7dca0b199e7ce51edbcd60 (diff)
Fix possible future overflow in zfs_nicenum
The function zfs_nicenum that converts number to human-readable output uses a index to a string of letters. This patch limits the index to the length of the string. Signed-off-by: Christer Ekholm <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #3122
Diffstat (limited to 'lib/libzfs/libzfs_util.c')
-rw-r--r--lib/libzfs/libzfs_util.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c
index 7f947c186..d212858d5 100644
--- a/lib/libzfs/libzfs_util.c
+++ b/lib/libzfs/libzfs_util.c
@@ -571,7 +571,7 @@ zfs_nicenum(uint64_t num, char *buf, size_t buflen)
int index = 0;
char u;
- while (n >= 1024) {
+ while (n >= 1024 && index < 6) {
n /= 1024;
index++;
}