diff options
author | 2012-02-13 14:27:15 +0100 | |
---|---|---|
committer | 2012-02-13 14:40:46 +0100 | |
commit | 9034699cb17e867c4fa0cc8b3e863eeaad822216 (patch) | |
tree | fd4f2a9dea89d5dd6cdff1166d14a1ef3d413689 | |
parent | Revert "qemu: add ibmvscsi controller model" (diff) | |
download | libvirt-9034699cb17e867c4fa0cc8b3e863eeaad822216.tar.gz libvirt-9034699cb17e867c4fa0cc8b3e863eeaad822216.tar.bz2 libvirt-9034699cb17e867c4fa0cc8b3e863eeaad822216.zip |
virpidfile: Allow whitespace character at the end of pidfile
Some programs, notably dnsmasq, which are writing pidfiles on their
own do append a whitespace character after pid, e.g. '\n'.
-rw-r--r-- | src/util/virpidfile.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index 34d125000..9c299673a 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -34,7 +34,7 @@ #include "intprops.h" #include "logging.h" #include "virterror_internal.h" - +#include "c-ctype.h" #define VIR_FROM_THIS VIR_FROM_NONE @@ -119,6 +119,7 @@ int virPidFileReadPath(const char *path, ssize_t bytes; long long pid_value = 0; char pidstr[INT_BUFSIZE_BOUND(pid_value)]; + char *endptr = NULL; *pid = 0; @@ -135,7 +136,8 @@ int virPidFileReadPath(const char *path, } 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; |