diff options
author | markj <markj@FreeBSD.org> | 2017-08-30 02:08:34 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2017-08-30 02:08:34 +0000 |
commit | 388b3c70dece24f762f366219ce6a2872dd58c3f (patch) | |
tree | 5c167f63f2fb4688baa406b822af6d1e851d71ae | |
parent | 9eba5d5cb4b651ab2868c60c111a5e3214072036 (diff) | |
download | FreeBSD-src-388b3c70dece24f762f366219ce6a2872dd58c3f.zip FreeBSD-src-388b3c70dece24f762f366219ce6a2872dd58c3f.tar.gz |
MFC r322773-r322775:
Fix an off-by-two in the llquantize() action parameter validation.
3 files changed, 28 insertions, 2 deletions
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/llquantize/err.D_LLQUANT_MAGTOOBIG.offbyone.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/llquantize/err.D_LLQUANT_MAGTOOBIG.offbyone.d new file mode 100644 index 0000000..47dccaf --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/llquantize/err.D_LLQUANT_MAGTOOBIG.offbyone.d @@ -0,0 +1,25 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2017 Mark Johnston <markj@FreeBSD.org> + */ + +/* + * A regression test for FreeBSD r322773. 100^9 fits in 64 bits, but + * llquantize() will create buckets up to 100^{10}, which does not fit. + */ + +BEGIN +{ + @ = llquantize(0, 100, 0, 9, 100); + exit(0); +} diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c index 84f8661..495e225 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c @@ -1546,7 +1546,7 @@ dt_compile_agg(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp) "divide a power of the factor\n"); } - for (i = 0, order = 1; i < args[2].value; i++) { + for (i = 0, order = 1; i <= args[2].value + 1; i++) { if (order * args[0].value > order) { order *= args[0].value; continue; @@ -1554,7 +1554,7 @@ dt_compile_agg(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp) dnerror(dnp, D_LLQUANT_MAGTOOBIG, "llquantize( ) " "factor (%d) raised to power of high magnitude " - "(%d) overflows 64-bits\n", args[0].value, + "(%d) plus 1 overflows 64-bits\n", args[0].value, args[2].value); } diff --git a/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile b/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile index be71bec..ed99dd1 100644 --- a/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile @@ -22,6 +22,7 @@ ${PACKAGE}FILES= \ err.D_LLQUANT_LOWVAL.d \ err.D_LLQUANT_MAGRANGE.d \ err.D_LLQUANT_MAGTOOBIG.d \ + err.D_LLQUANT_MAGTOOBIG.offbyone.d \ err.D_LLQUANT_NSTEPMATCH.d \ err.D_LLQUANT_NSTEPTYPE.d \ err.D_LLQUANT_NSTEPVAL.d \ |