From a056fdea2d83029cd955ead158303ecdf78a805d Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Fri, 12 Jan 2018 10:09:35 +0900 Subject: [PATCH] regx/fwd: correctly handle node names with multiple set of digits Refs. open-mpi/ompi#4689 Signed-off-by: Gilles Gouaillardet --- orte/mca/regx/fwd/regx_fwd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orte/mca/regx/fwd/regx_fwd.c b/orte/mca/regx/fwd/regx_fwd.c index 87250172a1..311f20051a 100644 --- a/orte/mca/regx/fwd/regx_fwd.c +++ b/orte/mca/regx/fwd/regx_fwd.c @@ -170,14 +170,12 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex) len = strlen(node); startnum = -1; memset(prefix, 0, ORTE_MAX_NODE_PREFIX); - numdigits = 0; for (i=0, j=0; i < len; i++) { /* valid hostname characters are ascii letters, digits and the '-' character. */ if (isdigit(node[i])) { /* count the size of the numeric field - but don't * add the digits to the prefix */ - numdigits++; if (startnum < 0) { /* okay, this defines end of the prefix */ startnum = i; @@ -204,8 +202,10 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex) nodenum = strtol(&node[startnum], &sfx, 10); if (NULL != sfx) { suffix = strdup(sfx); + numdigits = (int)(sfx - &node[startnum]); } else { suffix = NULL; + numdigits = (int)strlen(&node[startnum]); } /* is this node name already on our list? */ found = false;