From 666fdeab8fb3514116d31f535fd14f46f5e3c5be Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Tue, 7 Jun 2011 03:20:01 +0000 Subject: [PATCH] Okay to return an error on end=start of string conversion so long as the strlen > 0, so restore that error check. This commit was SVN r24756. --- opal/util/if.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/opal/util/if.c b/opal/util/if.c index bb96abad24..a1c4281bef 100644 --- a/opal/util/if.c +++ b/opal/util/if.c @@ -497,19 +497,19 @@ static uint32_t parse_ipv4_dots(const char *addr, uint32_t* net, int* dots) int i, rc = OPAL_SUCCESS; /* now assemble the address */ - for( i = 0; i < 4; i++ ) { + for( i = 0; i < 4 && 0 < strlen(start); i++ ) { n[i] = strtoul(start, (char**)&end, 10); if( end == start ) { /* error case: use what we have so far */ - rc = OPAL_SUCCESS; + rc = OPAL_ERR_NETWORK_NOT_PARSEABLE; break; } - /* skip all the . */ - for( start = end; '\0' != *start; start++ ) - if( '.' != *start ) break; /* did we read something sensible? */ if( n[i] > 255 ) { return OPAL_ERR_NETWORK_NOT_PARSEABLE; } + /* skip all the . */ + for( start = end; '\0' != *start; start++ ) + if( '.' != *start ) break; } *dots = i; *net = OPAL_IF_ASSEMBLE_NETWORK(n[0], n[1], n[2], n[3]);