Skip to content

Commit 45fb910

Browse files
committed
hwloc-calc: improve --cpukind parsing
Assume it's a number only if it starts with a digit. Error-out otherwise, so that things like foo:bar instead of foo=bar are rejected. Signed-off-by: Brice Goglin <[email protected]>
1 parent a19854a commit 45fb910

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

utils/hwloc/hwloc-calc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,11 @@ int main(int argc, char *argv[])
399399
cpukind_infoname = argv[1];
400400
cpukind_infovalue = equal+1;
401401
*equal = 0;
402-
} else {
402+
} else if (argv[1][0] >= '0' && argv[1][0] <= '9') {
403403
cpukind_index = atoi(argv[1]);
404+
} else {
405+
fprintf(stderr, "Failed to recognize --cpukind argument %s\n", argv[1]);
406+
return EXIT_FAILURE;
404407
}
405408
opt = 1;
406409
goto next_config;

0 commit comments

Comments
 (0)