Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Prevent a potential out of bounds read if one days some files are larger than Exabyte
Baptiste Daroussin committed 10 years ago
commit ce582b6d7d4dc82a57b4c0716693b66a537d356c
parent 3985279
1 file changed +4 -1
modified libpkg/pkg_printf.c
@@ -2055,7 +2055,7 @@ human_number(struct sbuf *sbuf, int64_t number, struct percent_esc *p)
#define MAXSCALE	7

	const char	 *bin_pfx[MAXSCALE] =
-
		{ "", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei" }; 
+
		{ "", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei" };
	const char	 *si_pfx[MAXSCALE] =
		{ "", "k", "M", "G", "T", "P", "E" };
	char		 format[16];
@@ -2083,6 +2083,9 @@ human_number(struct sbuf *sbuf, int64_t number, struct percent_esc *p)
		num /= divisor;
	}

+
	if (scale == MAXSCALE)
+
		scale--;
+

	if (scale == 0)
		scale_width = 0;
	else if (bin_scale)