From a12a9502fdd259ba47a01d1eab08d0e67fcb54d3 Mon Sep 17 00:00:00 2001 From: Morris Jette <jette@schedmd.com> Date: Fri, 15 Jul 2011 12:49:47 -0700 Subject: [PATCH] handle recovering bad bgq coordinates If unpacking BGQ state information and a bad coordinate is read, then return a NULL pointer rather than going off the end of an array and causing an invalid memory error. --- src/plugins/select/bluegene/ba_bgq/block_allocator.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/select/bluegene/ba_bgq/block_allocator.c b/src/plugins/select/bluegene/ba_bgq/block_allocator.c index 08a3bed7460..49b1eae6ac1 100644 --- a/src/plugins/select/bluegene/ba_bgq/block_allocator.c +++ b/src/plugins/select/bluegene/ba_bgq/block_allocator.c @@ -383,6 +383,12 @@ extern void print_ba_request(select_ba_request_t* ba_request) extern ba_mp_t *coord2ba_mp(const uint16_t *coord) { + if ((coord[A] >= DIM_SIZE[A]) || (coord[X] >= DIM_SIZE[X]) || + (coord[Y] >= DIM_SIZE[Y]) || (coord[Z] >= DIM_SIZE[Z])) { + error("Invalid coordinate %d:%d:%d:%d", + coord[A], coord[X], coord[Y], coord[Z]); + return NULL; + } return &ba_main_grid[coord[A]][coord[X]][coord[Y]][coord[Z]]; } -- GitLab