diff --git a/src/smap/configure_functions.c b/src/smap/configure_functions.c index a4037c7b324272f553fac23bd03d0f4b7ecfac4e..d55b96e50dc55992df46c58a7574ec67acda493d 100644 --- a/src/smap/configure_functions.c +++ b/src/smap/configure_functions.c @@ -584,11 +584,15 @@ static int _change_state_bps(char *com, int state) #ifdef HAVE_BG if ((com[i+3] == 'x') || (com[i+3] == '-')) { - for(j=0; j<3; j++) - if((i+j)>len - || (com[i+j] < '0' || com[i+j] > 'Z' - || (com[i+j] > '9' && com[i+j] < 'A'))) - goto error_message2; + for(j=0; j<3; j++) { + if (((i+j) <= len) && + (((com[i+j] >= '0') && (com[i+j] <= '9')) || + ((com[i+j] >= 'A') && (com[i+j] <= 'Z')) || + ((com[i+j] >= 'a') && (com[i+j] <= 'z')))) + continue; + goto error_message2; + + } number = xstrntol(com + i, NULL, BA_SYSTEM_DIMENSIONS, HOSTLIST_BASE); start[X] = number / (HOSTLIST_BASE * HOSTLIST_BASE); @@ -597,11 +601,14 @@ static int _change_state_bps(char *com, int state) start[Z] = (number % HOSTLIST_BASE); i += 4; - for(j=0; j<3; j++) - if((i+j)>len - || (com[i+j] < '0' || com[i+j] > 'Z' - || (com[i+j] > '9' && com[i+j] < 'A'))) - goto error_message2; + for(j=0; j<3; j++) { + if (((i+j) <= len) && + (((com[i+j] >= '0') && (com[i+j] <= '9')) || + ((com[i+j] >= 'A') && (com[i+j] <= 'Z')) || + ((com[i+j] >= 'a') && (com[i+j] <= 'z')))) + continue; + goto error_message2; + } number = xstrntol(com + i, NULL, BA_SYSTEM_DIMENSIONS, HOSTLIST_BASE); end[X] = number / (HOSTLIST_BASE * HOSTLIST_BASE); @@ -609,11 +616,14 @@ static int _change_state_bps(char *com, int state) / HOSTLIST_BASE; end[Z] = (number % HOSTLIST_BASE); } else { - for(j=0; j<3; j++) - if((i+j)>len - || (com[i+j] < '0' || com[i+j] > 'Z' - || (com[i+j] > '9' && com[i+j] < 'A'))) - goto error_message2; + for(j=0; j<3; j++) { + if (((i+j) <= len) && + (((com[i+j] >= '0') && (com[i+j] <= '9')) || + ((com[i+j] >= 'A') && (com[i+j] <= 'Z')) || + ((com[i+j] >= 'a') && (com[i+j] <= 'z')))) + continue; + goto error_message2; + } number = xstrntol(com + i, NULL, BA_SYSTEM_DIMENSIONS, HOSTLIST_BASE); start[X] = end[X] = number / (HOSTLIST_BASE * HOSTLIST_BASE); diff --git a/src/smap/partition_functions.c b/src/smap/partition_functions.c index 5445894088c9fba31245081e2aec3dea90e1d565..06aaef5b271150166a420d6f12017663aa2da469 100644 --- a/src/smap/partition_functions.c +++ b/src/smap/partition_functions.c @@ -901,6 +901,7 @@ static int _make_nodelist(char *nodes, List nodelist) break; j--; } else if((nodes[j] >= '0' && nodes[j] <= '9') + || (nodes[j] >= 'a' && nodes[j] <= 'z') || (nodes[j] >= 'A' && nodes[j] <= 'Z')) { number = xstrntol(nodes + j, NULL,