diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2019-09-29 17:52:03 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2019-09-29 17:52:03 +0000 |
commit | 50c932d4ace0f3e11bbf360937a31c31905ea1c1 (patch) | |
tree | 9d6ce1522590b01656eba1f8fd8eebc3eeb21355 | |
parent | a2cc3b13afc4925f7d50b37edc848e96fde6c141 (diff) |
Fix histogram code to do an inclusive check for the upper bound to
avoid an out-of-bound write for specific values and also check for
oob writes in general; with input from kettenis; ok florian@ kn@
-rw-r--r-- | sbin/unwind/resolver.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sbin/unwind/resolver.c b/sbin/unwind/resolver.c index 400fa7f12c6..b3f90782175 100644 --- a/sbin/unwind/resolver.c +++ b/sbin/unwind/resolver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resolver.c,v 1.43 2019/09/29 13:18:39 florian Exp $ */ +/* $OpenBSD: resolver.c,v 1.44 2019/09/29 17:52:02 otto Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -654,11 +654,13 @@ resolve_done(void *arg, int rcode, void *answer_packet, int answer_len, ms = elapsed.tv_sec * 1000 + elapsed.tv_nsec / 1000000; for (i = 1; i < nitems(histogram_limits); i++) { - if (ms > histogram_limits[i - 1] && ms < histogram_limits[i]) + if (ms > histogram_limits[i - 1] && ms <= histogram_limits[i]) break; } - - res->histogram[i]++; + if (i == nitems(histogram_limits)) + log_debug("histogram bucket error"); + else + res->histogram[i]++; log_debug("%s: async_id: %d, ref_cnt: %d, elapsed: %lldms, " "histogram: %lld - %lld", __func__, query_imsg->async_id, |