Accept whole range of supported pids
authorJakub Jelen <jjelen@redhat.com>
Thu, 24 Jun 2021 08:24:31 +0000 (10:24 +0200)
committerAndreas Schneider <asn@samba.org>
Fri, 25 Jun 2021 07:23:30 +0000 (09:23 +0200)
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
src/pam_wrapper.c

index 6801d7b32ef90b8d2173b51738ec37aa61ae8163..efa7cbb71a7d1c33ff77f80b4d002852a8ff72a9 100644 (file)
@@ -791,14 +791,20 @@ static void pwrap_clean_stale_dirs(const char *dir)
        buf[sizeof(buf) - 1] = '\0';
 
        tmp = strtol(buf, NULL, 10);
-       if (tmp == 0 || tmp > 0xFFFF || errno == ERANGE) {
+       if (tmp == 0 || errno == ERANGE) {
                PWRAP_LOG(PWRAP_LOG_ERROR,
                          "Failed to parse pid, buf=%s",
                          buf);
                return;
        }
 
-       pid = (pid_t)(tmp & 0xFFFF);
+       pid = (pid_t)tmp;
+       /* Check if we are out of pid_t range on this system */
+       if ((long)pid != tmp) {
+               PWRAP_LOG(PWRAP_LOG_ERROR,
+                         "pid out of range: %ld", tmp);
+               return;
+       }
 
        rc = kill(pid, 0);
        if (rc == -1) {