Skip to content

Commit 7fb7dc4

Browse files
committed
pqos: Allocation command (-a option) hangs with invalid core number.
This bug is fixed. Signed-off-by: Raghavan Kanagaraj <raghavan.kanagaraj@intel.com>
1 parent e96831d commit 7fb7dc4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pqos/alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ fill_core_tab(char *str)
966966
*p = '\0';
967967

968968
cos = (unsigned)strtouint64(str);
969-
n = strlisttotabrealloc(p + 1, &cores, &max_cores_count);
969+
n = strlisttotab(p + 1, cores, max_cores_count);
970970

971971
if (n == 0)
972972
goto normal_exit;

pqos/main.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "profiles.h"
4545

4646
#include <ctype.h> /**< isspace() */
47+
#include <errno.h>
4748
#include <fcntl.h>
4849
#include <getopt.h> /**< getopt_long() */
4950
#include <limits.h>
@@ -187,8 +188,20 @@ strtouint64_base(const char *s, int default_base)
187188
s += 2;
188189
}
189190

191+
errno = 0;
190192
n = strtoull(s, &endptr, base);
191193

194+
/* Check for various possible errors */
195+
if ((errno == ERANGE && n == ULLONG_MAX) || (errno != 0 && n == 0)) {
196+
perror("strtoull");
197+
exit(EXIT_FAILURE);
198+
}
199+
200+
if (endptr == s) {
201+
printf("No digits were found\n");
202+
exit(EXIT_FAILURE);
203+
}
204+
192205
if (!(*s != '\0' && *endptr == '\0')) {
193206
printf("Error converting '%s' to unsigned number!\n", str);
194207
exit(EXIT_FAILURE);

0 commit comments

Comments
 (0)