Skip to contentSkip to conversation

libxl: fix libxl_get_cpu_topology

PATCH In review Wei Liu 3 participants 3 messages Mar 13, 2012

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 libxl: fix libxl_get_cpu_topology

Fix upper bound of for loop, thus preventing memory corruption.

---
 tools/libxl/libxl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/libxl/libxl.c +1 -1
index d7eb2c5..f7b8bb5 100644
@@ -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);
Signature · 1 line
1.7.2.5
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Wei Liu

Fix upper bound of for loop, thus preventing memory corruption.

Quoted 17 lines
---
 tools/libxl/libxl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/libxl/libxl.c +1 -1
index d7eb2c5..f7b8bb5 100644
@@ -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);