anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0053-systemctl-check-validity-of-PID-we-received.patch

1ff636
From 3b573e5c39f452f98084b3d36486369882455b72 Mon Sep 17 00:00:00 2001
1ff636
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
1ff636
Date: Sat, 7 Feb 2015 11:16:04 -0500
1ff636
Subject: [PATCH] systemctl: check validity of PID we received
1ff636
1ff636
(cherry picked from commit d028e01814a405e83c400c60545785d35dba2a17)
1ff636
---
1ff636
 src/systemctl/systemctl.c | 5 ++++-
1ff636
 1 file changed, 4 insertions(+), 1 deletion(-)
1ff636
1ff636
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
1ff636
index 6b93ec8..3da4d3d 100644
1ff636
--- a/src/systemctl/systemctl.c
1ff636
+++ b/src/systemctl/systemctl.c
1ff636
@@ -2881,6 +2881,9 @@ static int check_inhibitors(sd_bus *bus, enum action a) {
1ff636
                 if (!sv)
1ff636
                         return log_oom();
1ff636
 
1ff636
+                if ((pid_t) pid < 0)
1ff636
+                        return log_error_errno(ERANGE, "Bad PID %"PRIu32": %m", pid);
1ff636
+
1ff636
                 if (!strv_contains(sv,
1ff636
                                   a == ACTION_HALT ||
1ff636
                                   a == ACTION_POWEROFF ||
1ff636
@@ -2892,7 +2895,7 @@ static int check_inhibitors(sd_bus *bus, enum action a) {
1ff636
                 user = uid_to_name(uid);
1ff636
 
1ff636
                 log_warning("Operation inhibited by \"%s\" (PID "PID_FMT" \"%s\", user %s), reason is \"%s\".",
1ff636
-                            who, pid, strna(comm), strna(user), why);
1ff636
+                            who, (pid_t) pid, strna(comm), strna(user), why);
1ff636
 
1ff636
                 c++;
1ff636
         }