From 8bdcfb53966313e9ff747e3028390c207cfdbe9a Mon Sep 17 00:00:00 2001 From: Christer Ekholm Date: Thu, 19 Feb 2015 22:44:53 +0100 Subject: [PATCH] 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 Signed-off-by: Brian Behlendorf Closes #3122 --- lib/libzfs/libzfs_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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++; }