freebsd-nq/lib/libutil
Bartek Rutkowski e285e32e56 humanize_number(3): fix math edge case in rounding large numbers
Fix for remainder overflow, when in rare cases adding remainder to divider
exceeded 1 and turned the total to 1000 in final formatting, taking up
the space for the unit character.

The fix continues the division of the original number if the above case
happens -- added the appropriate check to the for loop performing
the division. This lowers the value shown, to make it fit into the buffer
space provided (1.0M for 4+1 character buffer, as used by ls).

Add test case for the reported bug and extend test program to support
providing buffer length (ls -lh uses 5, tests hard-coded 4).

PR:		224498
Submitted by:	Pawel Biernacki <pawel.biernacki@gmail.com>
Reported by:	Masachika Ishizuka <ish@amail.plala.or.jp>
Reviewed by:	cem, kib
Approved by:	cem, kib
MFC after:	1 week
Sponsored by:	Mysterious Code Ltd.
Differential Revision:	D13578
2017-12-28 22:57:34 +00:00
..
tests humanize_number(3): fix math edge case in rounding large numbers 2017-12-28 22:57:34 +00:00
_secure_path.3
_secure_path.c
auth.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
expand_number.3
expand_number.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
flopen.3 Introduce the flopenat(3) function. 2017-08-04 14:24:24 +00:00
flopen.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
fparseln.3
fparseln.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
gr_util.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
hexdump.3 Fix some nroff style issue 2017-11-11 14:39:13 +00:00
hexdump.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
humanize_number.3 humanize_number(3): fix math edge case in rounding large numbers 2017-12-28 22:57:34 +00:00
humanize_number.c humanize_number(3): fix math edge case in rounding large numbers 2017-12-28 22:57:34 +00:00
kinfo_getallproc.3
kinfo_getallproc.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
kinfo_getfile.3
kinfo_getfile.c lib/libutil/kinfo_*: style cleanup 2017-01-09 00:47:23 +00:00
kinfo_getproc.3
kinfo_getproc.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
kinfo_getvmmap.3 Add caveat to kinfo_getvmmap(3) explaining high CPU utilisation. 2017-08-18 16:42:58 +00:00
kinfo_getvmmap.c lib/libutil/kinfo_*: style cleanup 2017-01-09 00:47:23 +00:00
kinfo_getvmobject.3
kinfo_getvmobject.c When sysctlbyname fails, free buf before returning. 2017-06-01 16:44:39 +00:00
kld.3
kld.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
libutil.h lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
login_auth.3
login_auth.c libutil: minor spelling fixes. 2016-05-18 15:25:45 +00:00
login_cap.3
login_cap.c lib: initial use of reallocarray(3). 2017-04-21 19:27:33 +00:00
login_cap.h
login_class.3 Fix handling of umtxp resource limit in sh(1)/ulimit(1), limits(1), add 2016-03-12 14:54:34 +00:00
login_class.c Fix handling of umtxp resource limit in sh(1)/ulimit(1), limits(1), add 2016-03-12 14:54:34 +00:00
login_crypt.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
login_ok.3
login_ok.c
login_times.3
login_times.c
login_tty.3
login_tty.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
login.conf.5 Fix handling of umtxp resource limit in sh(1)/ulimit(1), limits(1), add 2016-03-12 14:54:34 +00:00
Makefile MFhead@r322057 2017-08-04 17:41:49 +00:00
Makefile.depend DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
pidfile.3 libutil: minor spelling fixes. 2016-05-18 15:25:45 +00:00
pidfile.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
property.3
property.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
pty.3 Correct posix_openpt reference in pty(3) 2015-11-06 12:02:24 +00:00
pty.c Close slave on fork error to prevent pty fd leak. 2017-12-28 05:33:59 +00:00
pw_util.3 Bump .Dd due to changes made in r285050 and r285053 2015-07-02 19:41:08 +00:00
pw_util.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
quotafile.3
quotafile.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
realhostname_sa.3
realhostname.3
realhostname.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
stub.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
trimdomain.3
trimdomain.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
uucplock.3
uucplock.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00