This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 7.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 4f2aa690b313796f3069f78e56c6ec1392e79b28 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. (cherry picked from commit aa97de6162ac53f733c1e7a97fcb2350779d6ed8) --- 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 a830b79..8e3bd77 100644 --- a/iocore/hostdb/P_HostDBProcessor.h +++ b/iocore/hostdb/P_HostDBProcessor.h @@ -373,7 +373,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.