mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
torture: Accept whole pid_t range
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
e42307bbe3
commit
d2a32ca6d3
@@ -196,6 +196,7 @@ torture_read_pidfile(const char *pidfile)
|
|||||||
{
|
{
|
||||||
char buf[8] = {0};
|
char buf[8] = {0};
|
||||||
long int tmp;
|
long int tmp;
|
||||||
|
pid_t ret;
|
||||||
ssize_t rc;
|
ssize_t rc;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
@@ -213,11 +214,16 @@ torture_read_pidfile(const char *pidfile)
|
|||||||
buf[sizeof(buf) - 1] = '\0';
|
buf[sizeof(buf) - 1] = '\0';
|
||||||
|
|
||||||
tmp = strtol(buf, NULL, 10);
|
tmp = strtol(buf, NULL, 10);
|
||||||
if (tmp == 0 || tmp > 0xFFFF || errno == ERANGE) {
|
if (tmp == 0 || errno == ERANGE) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ret = (pid_t)tmp;
|
||||||
|
/* Check if we are out of pid_t range on this system */
|
||||||
|
if ((long)ret != tmp) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (pid_t)(tmp & 0xFFFF);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int torture_terminate_process(const char *pidfile)
|
int torture_terminate_process(const char *pidfile)
|
||||||
|
|||||||
Reference in New Issue
Block a user