mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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'.
This commit is contained in:
parent
ded8e894dd
commit
9034699cb1
@ -34,7 +34,7 @@
|
|||||||
#include "intprops.h"
|
#include "intprops.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "virterror_internal.h"
|
#include "virterror_internal.h"
|
||||||
|
#include "c-ctype.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
@ -119,6 +119,7 @@ int virPidFileReadPath(const char *path,
|
|||||||
ssize_t bytes;
|
ssize_t bytes;
|
||||||
long long pid_value = 0;
|
long long pid_value = 0;
|
||||||
char pidstr[INT_BUFSIZE_BOUND(pid_value)];
|
char pidstr[INT_BUFSIZE_BOUND(pid_value)];
|
||||||
|
char *endptr = NULL;
|
||||||
|
|
||||||
*pid = 0;
|
*pid = 0;
|
||||||
|
|
||||||
@ -135,7 +136,8 @@ int virPidFileReadPath(const char *path,
|
|||||||
}
|
}
|
||||||
pidstr[bytes] = '\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) {
|
(pid_t) pid_value != pid_value) {
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user