From 823f26ed7b302a8de3169af9ddfb96f1b34246d4 Mon Sep 17 00:00:00 2001 From: Morris Jette <jette@schedmd.com> Date: Fri, 15 Jul 2011 13:25:58 -0700 Subject: [PATCH] Out of range check added for BGL/BGP array When reading an old state file, if the old coordinates would be out of bounds in the new array, return a NULL pointer rather than going off the end of the array and getting a segv. --- src/plugins/select/bluegene/ba/block_allocator.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/select/bluegene/ba/block_allocator.c b/src/plugins/select/bluegene/ba/block_allocator.c index 0ad3bd6d028..f593c0c25d3 100644 --- a/src/plugins/select/bluegene/ba/block_allocator.c +++ b/src/plugins/select/bluegene/ba/block_allocator.c @@ -682,6 +682,12 @@ extern int copy_node_path(List nodes, List *dest_nodes) extern ba_mp_t *coord2ba_mp(const uint16_t *coord) { + if ((coord[X] >= DIM_SIZE[X]) || (coord[Y] >= DIM_SIZE[Y]) || + (coord[Z] >= DIM_SIZE[Z])) { + error("Invalid coordinate %d:%d:%d", + coord[X], coord[Y], coord[Z]); + return NULL; + } return &ba_main_grid[coord[X]][coord[Y]][coord[Z]]; } -- GitLab