OpenBSD CVS

CVS log for src/lib/libutil/fmt_scaled.c


[BACK] Up to [local] / src / lib / libutil

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.23 / (download) - annotate - [select for diffs], Tue Dec 27 17:10:08 2022 UTC (17 months, 2 weeks ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, HEAD
Changes since 1.22: +2 -2 lines
Diff to previous 1.22 (colored)

spelling fixes; from paul tagliamonte
any changes not taken noted on tech, but chiefly here i did not take the
cancelation - cancellation changes;

Revision 1.22 / (download) - annotate - [select for diffs], Fri Mar 11 09:04:59 2022 UTC (2 years, 3 months ago) by dtucker
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.21: +1 -2 lines
Diff to previous 1.21 (colored)

Revert previous commit.  The problem it was attempting to fix was already
fixed by tb@ in rev 1.20.  Spotted by tb@

Revision 1.21 / (download) - annotate - [select for diffs], Fri Mar 11 07:29:53 2022 UTC (2 years, 3 months ago) by dtucker
Branch: MAIN
Changes since 1.20: +3 -2 lines
Diff to previous 1.20 (colored)

Check for underflow as well as overflow when scaling negative numbers.
ok millert@

Revision 1.20 / (download) - annotate - [select for diffs], Sun Jun 20 14:08:42 2021 UTC (2 years, 11 months ago) by tb
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.19: +6 -5 lines
Diff to previous 1.19 (colored)

scan_scaled: fix rescaling for negative numbers

As found by djm by fuzzing ssh, scan_scaled can overflow for negative
numbers when rescaling is needed. This is because the rescaled fractional
part is added without taking the sign into account.

ok ian jca

Revision 1.19 / (download) - annotate - [select for diffs], Mon Oct 12 22:08:34 2020 UTC (3 years, 7 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.18: +4 -4 lines
Diff to previous 1.18 (colored)

make fixed-sized fixed-value mib[] arrays be const
ok guenther tb millert

Revision 1.18 / (download) - annotate - [select for diffs], Mon Jan 14 23:52:06 2019 UTC (5 years, 4 months ago) by bluhm
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6, OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.17: +9 -5 lines
Diff to previous 1.17 (colored)

Calling llabs(LLONG_MIN) is undefined behavior, llvm 7.0.1 does not
work with our old code.  In fmt_scaled() move the check before
calling llabs().
found by regress/lib/libutil/fmt_scaled; OK deraadt@ millert@ tedu@

Revision 1.17 / (download) - annotate - [select for diffs], Mon May 14 04:39:04 2018 UTC (6 years ago) by djm
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.16: +5 -2 lines
Diff to previous 1.16 (colored)

constrain fractional part to [0-9] (less confusing to static analysis); ok ian@

Revision 1.16 / (download) - annotate - [select for diffs], Thu Mar 16 02:40:46 2017 UTC (7 years, 2 months ago) by dtucker
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.15: +11 -3 lines
Diff to previous 1.15 (colored)

Fix overly-conservative overflow checks on mulitplications and add checks
on additions.  This allows scan_scaled to work up to +/-LLONG_MAX (LLONG_MIN
will still be flagged as a range error).  ok millert@

Revision 1.15 / (download) - annotate - [select for diffs], Wed Mar 15 05:25:56 2017 UTC (7 years, 2 months ago) by dtucker
Branch: MAIN
Changes since 1.14: +4 -7 lines
Diff to previous 1.14 (colored)

Collapse underflow and overflow checks into a single block.
ok djm@ millert@

Revision 1.14 / (download) - annotate - [select for diffs], Wed Mar 15 00:13:18 2017 UTC (7 years, 2 months ago) by dtucker
Branch: MAIN
Changes since 1.13: +6 -1 lines
Diff to previous 1.13 (colored)

Catch integer underflow in scan_scaled reported by Nicolas Iooss.
ok deraadt@ djm@

Revision 1.13 / (download) - annotate - [select for diffs], Sat Mar 11 23:37:23 2017 UTC (7 years, 3 months ago) by djm
Branch: MAIN
Changes since 1.12: +14 -1 lines
Diff to previous 1.12 (colored)

fix signed integer overflow in scan_scaled. Found by Nicolas Iooss
using AFL against ssh_config. ok deraadt@ millert@

Revision 1.12 / (download) - annotate - [select for diffs], Fri Nov 29 19:00:51 2013 UTC (10 years, 6 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9, OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7, OPENBSD_5_6_BASE, OPENBSD_5_6, OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.11: +6 -5 lines
Diff to previous 1.11 (colored)

fairly simple unsigned char casts for ctype
ok krw

Revision 1.11 / (download) - annotate - [select for diffs], Mon Nov 12 14:07:20 2012 UTC (11 years, 7 months ago) by halex
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4, OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.10: +4 -2 lines
Diff to previous 1.10 (colored)

make scan_scaled set errno to EINVAL rather than ERANGE if it encounters
an invalid multiplier, like the man page says it should

"looks sensible" deraadt@, ok ian@

Revision 1.10 / (download) - annotate - [select for diffs], Sat Jun 20 15:00:04 2009 UTC (14 years, 11 months ago) by martynas
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2, OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8, OPENBSD_4_7_BASE, OPENBSD_4_7, OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.9: +4 -4 lines
Diff to previous 1.9 (colored)

use llabs instead of the home-grown version;  and some comment changes
ok ian@, millert@

Revision 1.9 / (download) - annotate - [select for diffs], Tue Mar 20 03:42:52 2007 UTC (17 years, 2 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5, OPENBSD_4_4_BASE, OPENBSD_4_4, OPENBSD_4_3_BASE, OPENBSD_4_3, OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.8: +4 -4 lines
Diff to previous 1.8 (colored)

remove some bogus *p from charles longeau
ok deraadt millert

Revision 1.8 / (download) - annotate - [select for diffs], Wed Oct 19 18:48:11 2005 UTC (18 years, 7 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1, OPENBSD_4_0_BASE, OPENBSD_4_0, OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.7: +1 -11 lines
Diff to previous 1.7 (colored)

library routines should not be checking for NULL pointers passed in,
and then setting errno to EFAULT.  that is balony programming!  they
should keep stumbling along to purposely create a crash, so that the
programmer stops doing that kind of stupid crap.  ok otto

Revision 1.7 / (download) - annotate - [select for diffs], Tue Aug 2 21:46:23 2005 UTC (18 years, 10 months ago) by espie
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.6: +1 -5 lines
Diff to previous 1.6 (colored)

scrape $Id$ tags.
okay deraadt@, millert@, krw@

Revision 1.6 / (download) - annotate - [select for diffs], Wed Mar 9 09:27:57 2005 UTC (19 years, 3 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.5: +10 -4 lines
Diff to previous 1.5 (colored)

Fix rounding of fractionless numbers. ok tom@ miod@

Revision 1.5 / (download) - annotate - [select for diffs], Tue Mar 8 15:35:35 2005 UTC (19 years, 3 months ago) by otto
Branch: MAIN
Changes since 1.4: +4 -9 lines
Diff to previous 1.4 (colored)

Fix sizing of fraction. ok tom@ deraadt@

Revision 1.4 / (download) - annotate - [select for diffs], Thu Sep 16 10:56:35 2004 UTC (19 years, 8 months ago) by otto
Branch: MAIN
Changes since 1.3: +3 -3 lines
Diff to previous 1.3 (colored)

fix 1099512676352 -> 2.0T; ok miod@

Revision 1.3 / (download) - annotate - [select for diffs], Fri May 28 07:03:47 2004 UTC (20 years ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.2: +4 -3 lines
Diff to previous 1.2 (colored)

knf; otto ok

Revision 1.2 / (download) - annotate - [select for diffs], Sat Dec 27 19:49:51 2003 UTC (20 years, 5 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5
Changes since 1.1: +8 -5 lines
Diff to previous 1.1 (colored)

o Do not drop unit when printing -100
o Round negative numbers correctly
o Do not print fractional valus for byte values

ok ian@ henning@

Revision 1.1 / (download) - annotate - [select for diffs], Thu May 15 01:26:26 2003 UTC (21 years, 1 month ago) by ian
Branch: MAIN
CVS Tags: OPENBSD_3_4_BASE, OPENBSD_3_4

New: fmt_scaled() and scan_scaled() convert to and from "human readable"
or scaled numbers. fmt_scaled, and the format, based on Ken Stailey's
code for "df -h"; scan_scaled is new. Significantly commented on
and reworked by pjanzen@; other comments from millert@.  OK pjanzen@.

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.