Fix upper bound of for loop, thus preventing memory corruption. Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- tools/libxl/libxl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index d7eb2c5..f7b8bb5 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -2872,7 +2872,7 @@ libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nr) goto fail; } - for (i = 0; i <= max_cpus; i++) { + for (i = 0; i < max_cpus; i++) { #define V(map, i) (map[i] == INVALID_TOPOLOGY_ID) ? \ LIBXL_CPUTOPOLOGY_INVALID_ENTRY : map[i] ret[i].core = V(coremap, i); -- 1.7.2.5
On Tue, 2012-03-13 at 10:09 +0000, Wei Liu wrote:> Fix upper bound of for loop, thus preventing memory corruption. > > Signed-off-by: Wei Liu <wei.liu2@citrix.com>Acked-by: Ian Campbell <ian.campbell@citrix.com>> --- > tools/libxl/libxl.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > index d7eb2c5..f7b8bb5 100644 > --- a/tools/libxl/libxl.c > +++ b/tools/libxl/libxl.c > @@ -2872,7 +2872,7 @@ libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nr) > goto fail; > } > > - for (i = 0; i <= max_cpus; i++) { > + for (i = 0; i < max_cpus; i++) { > #define V(map, i) (map[i] == INVALID_TOPOLOGY_ID) ? \ > LIBXL_CPUTOPOLOGY_INVALID_ENTRY : map[i] > ret[i].core = V(coremap, i);
Ian Campbell writes ("Re: [Xen-devel] [PATCH] libxl: fix libxl_get_cpu_topology"):> On Tue, 2012-03-13 at 10:09 +0000, Wei Liu wrote: > > Fix upper bound of for loop, thus preventing memory corruption. > > > > Signed-off-by: Wei Liu <wei.liu2@citrix.com> > Acked-by: Ian Campbell <ian.campbell@citrix.com>Thanks. Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>