summaryrefslogtreecommitdiffstats
path: root/lib/libutil/humanize_number.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r316766:brooks2017-04-241-2/+2
| | | | | | | | | | | | | | | | Correct an out of bounds read with HN_AUTOSCALE and very large numbers. The maximum scale is 6 (K, M, G, T, P, E) (B is 0). Overly large explict scales were checked correctly, but for sufficently large numbers HN_AUTOSCALE would get to 7 resulting in an out of bounds read. Found with humanize_number_test and CHERI bounds checking. Reviewed by: emaste Obtained from: CheriBSD Sponsored by: DARPA, AFRL
* don't assert on bad args, instead return an error..jmg2013-10-071-31/+43
| | | | | | | | | | | | | | | Since so many programs don't check return value, always NUL terminate the buf... fix rounding when using base 1024 (the bug that started it all)... add a set of test cases so we can make sure that things don't break in the future... Thanks to Clifton Royston for testing and the test program... Approved by: re (hrs, glebius) MFC after: 1 week
* Fix IEC / SI binary prefixes (Ki, Mi, Gi, etc) production by humanize_number(3)bapt2012-09-121-1/+1
| | | | | | PR: bin/171487 Submitted by: matthew MFC after: 1 week
* Add support for IEE/IEC (and now also SI) power of two notions ofdelphij2011-04-121-19/+32
| | | | | | | | | | prefixes (Ki, Mi, Gi...) for humanize_number(3). Note that applications has to pass HN_IEC_PREFIXES to use this feature for backward compatibility reasons. Reviewed by: arundel MFC after: 2 weeks
* humanize_number(3) multiply the input number by 100, which could cause andelphij2011-03-231-16/+24
| | | | | | | | | | | | integer overflow when the input is very large (for example, 100 Pi would become about 10 Ei which exceeded signed int64_t). Solve this issue by splitting the division into two parts and avoid the multiplication. PR: bin/146205 Reviewed by: arundel MFC after: 1 month
* Merge NetBSD revision 1.14: humanize_number.c is now 2-clause BSD licensed.delphij2009-06-231-8/+1
| | | | | | | (humanize_number.3 intentionally hold back until I make sure why we didn't merged dehumanize_number(3)). Obtained from: NetBSD
* Merge changes from NetBSD on humanize_number.c, 1.8 -> 1.13antoine2008-03-081-5/+10
| | | | | | | | | | | | | | Significant changes: - rev. 1.11: Use PRId64 instead of a cast to long long and %lld to print an int64_t. - rev. 1.12: Fix a bug that humanize_number() produces "1000" where it should be "1.0G" or "1.0M". The bug reported by Greg Troxel. PR: 118461 PR: 102694 Approved by: rwatson (mentor) Obtained from: NetBSD MFC after: 1 month
* Take the lastest fixes from NetBSD.pjd2004-09-251-63/+51
| | | | Obtained from: NetBSD
* Add humanize_number(3) to libutil for formating numbers into a humanpjd2004-05-241-0/+160
readable form. Obtained from: NetBSD
OpenPOWER on IntegriCloud