diff options
author | George Kadianakis <desnacked@riseup.net> | 2015-01-15 14:36:24 +0000 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2015-01-15 14:43:58 +0000 |
commit | 45bc5a07434376c0d801a547b38893d85a515b49 (patch) | |
tree | 3569b85366fbfabc6db75a3df054990e13a5ea59 /src/test/test_util.c | |
parent | 3668a4126e0c2502a77c2ba5d7885add489a964a (diff) | |
download | tor-45bc5a07434376c0d801a547b38893d85a515b49.tar.gz tor-45bc5a07434376c0d801a547b38893d85a515b49.zip |
Restrict sample values of the Laplace distribution to int64_t.
This helps avoid undefined behavior from casting big double values to
int64_t. Fixes #14090.
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 15470e8efa..75727a4bcc 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -4654,11 +4654,11 @@ test_util_laplace(void *arg) const double delta_f = 15.0, epsilon = 0.3; /* b = 15.0 / 0.3 = 50.0 */ (void)arg; - tt_assert(isinf(sample_laplace_distribution(mu, b, 0.0))); - test_feq(-69.88855213, sample_laplace_distribution(mu, b, 0.01)); - test_feq(24.0, sample_laplace_distribution(mu, b, 0.5)); - test_feq(24.48486498, sample_laplace_distribution(mu, b, 0.51)); - test_feq(117.88855213, sample_laplace_distribution(mu, b, 0.99)); + tt_int_op(INT64_MIN, ==, sample_laplace_distribution(mu, b, 0.0)); + tt_int_op(-69, ==, sample_laplace_distribution(mu, b, 0.01)); + tt_int_op(24, ==, sample_laplace_distribution(mu, b, 0.5)); + tt_int_op(24, ==, sample_laplace_distribution(mu, b, 0.51)); + tt_int_op(117, ==, sample_laplace_distribution(mu, b, 0.99)); /* >>> laplace.ppf([0.0, 0.1, 0.25, 0.5, 0.75, 0.9, 0.99], * ... loc = 0, scale = 50) |