Some programs, notably dnsmasq, which are writing pidfiles on their
own do append a whitespace character after pid, e.g. '\n'.
#include "intprops.h"
#include "logging.h"
#include "virterror_internal.h"
-
+#include "c-ctype.h"
#define VIR_FROM_THIS VIR_FROM_NONE
ssize_t bytes;
long long pid_value = 0;
char pidstr[INT_BUFSIZE_BOUND(pid_value)];
+ char *endptr = NULL;
*pid = 0;
}
pidstr[bytes] = '\0';
- if (virStrToLong_ll(pidstr, NULL, 10, &pid_value) < 0 ||
+ if (virStrToLong_ll(pidstr, &endptr, 10, &pid_value) < 0 ||
+ !(*endptr == '\0' || c_isspace(*endptr)) ||
(pid_t) pid_value != pid_value) {
rc = -1;
goto cleanup;