Ruled out cases: word, number+word, word+number, number+word+number
Ex: foo, 123foo, foo123, 123foo123
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
int count = 0;
int *pid_list = NULL;
char *pid_string = NULL;
int count = 0;
int *pid_list = NULL;
char *pid_string = NULL;
if (all && _pid_string) {
ERR("An empty PID string is expected with --all");
if (all && _pid_string) {
ERR("An empty PID string is expected with --all");
while (one_pid_str != NULL) {
unsigned long v;
while (one_pid_str != NULL) {
unsigned long v;
- v = strtoul(one_pid_str, NULL, 10);
+ errno = 0;
+ v = strtoul(one_pid_str, &endptr, 10);
if ((v == 0 && errno == EINVAL)
if ((v == 0 && errno == EINVAL)
- || (v == ULONG_MAX && errno == ERANGE)) {
+ || (v == ULONG_MAX && errno == ERANGE)
+ || (*one_pid_str != '\0' && *endptr != '\0')){
ERR("Error parsing PID %s", one_pid_str);
retval = CMD_ERROR;
goto error;
}
ERR("Error parsing PID %s", one_pid_str);
retval = CMD_ERROR;
goto error;
}
if ((long) v > INT_MAX || (int) v < 0) {
ERR("Invalid PID value %ld", (long) v);
retval = CMD_ERROR;
if ((long) v > INT_MAX || (int) v < 0) {
ERR("Invalid PID value %ld", (long) v);
retval = CMD_ERROR;