Skip to content

Commit db68bd1

Browse files
UCP/CORE: Fix closing bracket detection for ranges
1 parent 94d32e7 commit db68bd1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/ucp/core/ucp_context.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,7 @@ static uint64_t ucp_str_array_search_in_ranges(const char **array,
10141014
const char *p;
10151015
char *endptr;
10161016
unsigned i;
1017+
int n;
10171018

10181019
result = 0;
10191020
for (i = 0; i < array_len; ++i) {
@@ -1027,8 +1028,9 @@ static uint64_t ucp_str_array_search_in_ranges(const char **array,
10271028
continue; /* Prefix does not match */
10281029
}
10291030

1030-
if (sscanf(p, "[%lu-%lu]", &range_start, &range_end) != 2 ||
1031-
range_start > range_end) {
1031+
n = 0;
1032+
if (sscanf(p, "[%lu-%lu]%n", &range_start, &range_end, &n) != 2 ||
1033+
n == 0 || p[n] != '\0' || range_start > range_end) {
10321034
ucs_warn("invalid device range: %s", array[i]);
10331035
continue;
10341036
}

0 commit comments

Comments
 (0)