Skip to content

Commit

Permalink
Fix possible future overflow in zfs_nicenum
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chrekh authored and behlendorf committed Feb 24, 2015
1 parent b4f3666 commit 8bdcfb5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/libzfs/libzfs_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down

0 comments on commit 8bdcfb5

Please sign in to comment.