This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push: new aa97de6 Fixed off-by-one error in select_best_srv. aa97de6 is described below commit aa97de6162ac53f733c1e7a97fcb2350779d6ed8 Author: Chris Lemmons <alfic...@gmail.com> AuthorDate: Tue May 8 15:54:42 2018 +0000 Fixed off-by-one error in select_best_srv. This error may never actually occur, it was reported by clang-analyzer. This just ensures that in no case does the loop run one past the end of the array. --- iocore/hostdb/P_HostDBProcessor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iocore/hostdb/P_HostDBProcessor.h b/iocore/hostdb/P_HostDBProcessor.h index 40bcdeb..ab84309 100644 --- a/iocore/hostdb/P_HostDBProcessor.h +++ b/iocore/hostdb/P_HostDBProcessor.h @@ -374,7 +374,7 @@ HostDBRoundRobin::select_best_srv(char *target, InkRand *rand, ink_time_t now, i result = &info(current++ % len); } else { uint32_t xx = rand->random() % weight; - for (i = 0; i < len && xx >= infos[i]->data.srv.srv_weight; ++i) + for (i = 0; i < len - 1 && xx >= infos[i]->data.srv.srv_weight; ++i) xx -= infos[i]->data.srv.srv_weight; result = infos[i]; -- To stop receiving notification emails like this one, please contact zw...@apache.org.