[Sheepdog] [PATCH] sheep: fix the memmove bug in del_cpg_node

Liu Yuan namei.unix at gmail.com
Thu Mar 1 08:12:34 CET 2012


On 03/01/2012 01:41 PM, yaohaiting.wujue at gmail.com wrote:

> From: HaiTing Yao <wujue.yht at taobao.com>
> 
> The size is not right, maybe lead to error
> 
> Signed-off-by: HaiTing Yao <wujue.yht at taobao.com>
> ---
>  sheep/cluster/corosync.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/sheep/cluster/corosync.c b/sheep/cluster/corosync.c
> index fcf1880..f6eec1d 100644
> --- a/sheep/cluster/corosync.c
> +++ b/sheep/cluster/corosync.c
> @@ -130,7 +130,7 @@ static inline void del_cpg_node(struct cpg_node *nodes, size_t nr_nodes,
>  	}
>  
>  	nr_nodes--;
> -	memmove(nodes + idx, nodes + idx + 1, sizeof(*nodes) * nr_nodes - idx);
> +	memmove(nodes + idx, nodes + idx + 1, sizeof(*nodes) * (nr_nodes - idx));
>  }
>  
>  static int nodeid_to_addr(uint32_t nodeid, uint8_t *addr)


Good catch. Applied, thanks.

Yuan



More information about the sheepdog mailing list