From 1b26d33a4e3a310dfc92946bf4fe0a04c337b165 Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Mon, 22 Oct 2007 18:52:11 +0000 Subject: [PATCH] Tweak the code so BGL hostname coordinates can contain upper or lower case letters --- src/smap/configure_functions.c | 40 +++++++++++++++++++++------------- src/smap/partition_functions.c | 1 + 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/smap/configure_functions.c b/src/smap/configure_functions.c index a4037c7b324..d55b96e50dc 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 5445894088c..06aaef5b271 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, -- GitLab