]> git.99rst.org Git - openwrt-packages.git/blob
28b9fe0a5433fdbdb7c308cfa195cecd37e4cb29
[openwrt-packages.git] /
1 commit 974c6916ba2f7efc83193bb8c04e95294ca21112
2 Author: Christopher Faulet <cfaulet@haproxy.com>
3 Date: Fri Jul 26 13:52:13 2019 +0200
4
5 BUG/MEDIUM: lb-chash: Fix the realloc() when the number of nodes is increased
6
7 When the number of nodes is increased because the server weight is changed, the
8 nodes array must be realloc. But its new size is not correctly set. Only the
9 total number of nodes is used to set the new size. But it must also depends on
10 the size of a node. It must be the total nomber of nodes times the size of a
11 node.
12
13 This issue was reported on Github (#189).
14
15 This patch must be backported to all versions since the 1.6.
16
17 (cherry picked from commit 366ad86af72c455cc958943913cb2de20eefee71)
18 Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
19
20 diff --git a/src/lb_chash.c b/src/lb_chash.c
21 index a35351e9..0bf4e81a 100644
22 --- a/src/lb_chash.c
23 +++ b/src/lb_chash.c
24 @@ -84,7 +84,7 @@ static inline void chash_queue_dequeue_srv(struct server *s)
25 * increased the weight beyond the original weight
26 */
27 if (s->lb_nodes_tot < s->next_eweight) {
28 - struct tree_occ *new_nodes = realloc(s->lb_nodes, s->next_eweight);
29 + struct tree_occ *new_nodes = realloc(s->lb_nodes, s->next_eweight * sizeof(*new_nodes));
30
31 if (new_nodes) {
32 unsigned int j;
git clone https://git.99rst.org/PROJECT