1
1

regx/fwd: correctly handle node names with multiple set of digits

Refs. open-mpi/ompi#4689

Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
Этот коммит содержится в:
Gilles Gouaillardet 2018-01-12 10:09:35 +09:00
родитель 8f02596777
Коммит a056fdea2d

Просмотреть файл

@ -170,14 +170,12 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex)
len = strlen(node); len = strlen(node);
startnum = -1; startnum = -1;
memset(prefix, 0, ORTE_MAX_NODE_PREFIX); memset(prefix, 0, ORTE_MAX_NODE_PREFIX);
numdigits = 0;
for (i=0, j=0; i < len; i++) { for (i=0, j=0; i < len; i++) {
/* valid hostname characters are ascii letters, digits and the '-' character. */ /* valid hostname characters are ascii letters, digits and the '-' character. */
if (isdigit(node[i])) { if (isdigit(node[i])) {
/* count the size of the numeric field - but don't /* count the size of the numeric field - but don't
* add the digits to the prefix * add the digits to the prefix
*/ */
numdigits++;
if (startnum < 0) { if (startnum < 0) {
/* okay, this defines end of the prefix */ /* okay, this defines end of the prefix */
startnum = i; startnum = i;
@ -204,8 +202,10 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex)
nodenum = strtol(&node[startnum], &sfx, 10); nodenum = strtol(&node[startnum], &sfx, 10);
if (NULL != sfx) { if (NULL != sfx) {
suffix = strdup(sfx); suffix = strdup(sfx);
numdigits = (int)(sfx - &node[startnum]);
} else { } else {
suffix = NULL; suffix = NULL;
numdigits = (int)strlen(&node[startnum]);
} }
/* is this node name already on our list? */ /* is this node name already on our list? */
found = false; found = false;