
phk at varnish-cache
Jul 15, 2013, 1:26 AM
Post #1 of 1
(44 views)
Permalink
|
|
[master] 65c8593 Fix boundary condition on an assert.
|
|
commit 65c8593dc828b0ac6944d3897cf33d64028c6c43 Author: Poul-Henning Kamp <phk [at] FreeBSD> Date: Mon Jul 15 08:25:19 2013 +0000 Fix boundary condition on an assert. Fixes #1324 diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index 43b4872..290909f 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -118,6 +118,7 @@ vmod_hash_backend(const struct vrt_ctx *ctx, struct vmod_directors_hash *rr, r = vbe32dec(sha256); r = scalbn(r, -32); + assert(r >= 0 && r <= 1.0); be = vdir_pick_be(rr->vd, ctx->bo, r, rr->nloops); return (be); } diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index a8dd8a7..6d2be1e 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -67,6 +67,7 @@ vmod_rr_getfd(const struct director *dir, struct busyobj *bo) CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_RANDOM_MAGIC); r = scalbn(random(), -31); + assert(r >= 0 && r < 1.0); be = vdir_pick_be(rr->vd, bo, r, rr->nloops); if (be == NULL) return (NULL); diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 62b0033..14d523d 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -180,7 +180,7 @@ vdir_pick_be(struct vdir *vd, const struct busyobj *bo, double w, tw = vd->total_weight; nbe = vd->n_backend; - assert(w >= 0.0 && w <= 1.0); + assert(w >= 0.0 && w < 1.0); vdir_lock(vd); for (l = 0; nbe > 0 && tw > 0.0 && l <nloops; l++) { u = vdir_pick_by_weight(vd, w * tw, vbm); _______________________________________________ varnish-commit mailing list varnish-commit [at] varnish-cache https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit
|