47 lines
1.2 KiB
Diff
47 lines
1.2 KiB
Diff
From b33dcda94d313913a877bc8db006ad02141bc695 Mon Sep 17 00:00:00 2001
|
|
From: Jakub Jelen <jjelen@redhat.com>
|
|
Date: Wed, 11 Dec 2019 11:07:33 +0100
|
|
Subject: [PATCH] torture: Accept whole pid_t range
|
|
|
|
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
|
|
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
|
|
(cherry picked from commit d2a32ca6d3c40483a6d10340d3e11da9259e1379)
|
|
---
|
|
tests/torture.c | 10 ++++++++--
|
|
1 file changed, 8 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/tests/torture.c b/tests/torture.c
|
|
index 360fd02a..907f45b3 100644
|
|
--- a/tests/torture.c
|
|
+++ b/tests/torture.c
|
|
@@ -196,6 +196,7 @@ torture_read_pidfile(const char *pidfile)
|
|
{
|
|
char buf[8] = {0};
|
|
long int tmp;
|
|
+ pid_t ret;
|
|
ssize_t rc;
|
|
int fd;
|
|
|
|
@@ -213,11 +214,16 @@ torture_read_pidfile(const char *pidfile)
|
|
buf[sizeof(buf) - 1] = '\0';
|
|
|
|
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 (pid_t)(tmp & 0xFFFF);
|
|
+ return ret;
|
|
}
|
|
|
|
int torture_terminate_process(const char *pidfile)
|
|
--
|
|
2.23.0
|
|
|