a4b143
From 07c3b93b709a601398ce5e06d48f215d097ed959 Mon Sep 17 00:00:00 2001
a4b143
From: Lukas Nykryn <lnykryn@redhat.com>
a4b143
Date: Tue, 24 Sep 2013 16:27:20 +0200
a4b143
Subject: [PATCH] logind: return -EINVAL when PID is wrong
a4b143
a4b143
dbus-send --print-reply --system --dest=org.freedesktop.login1
a4b143
/org/freedesktop/login1 org.freedesktop.login1.Manager.GetUserByPID
a4b143
uint32:0
a4b143
causes
a4b143
systemd-logind[29843]: Assertion 'pid >= 1' failed at
a4b143
src/login/logind.c:938, function manager_get_user_by_pid(). Aborting.
a4b143
---
a4b143
 src/login/logind.c | 8 ++++++--
a4b143
 1 file changed, 6 insertions(+), 2 deletions(-)
a4b143
a4b143
diff --git a/src/login/logind.c b/src/login/logind.c
a4b143
index 4ef92b8..afc737c 100644
a4b143
--- a/src/login/logind.c
a4b143
+++ b/src/login/logind.c
a4b143
@@ -914,9 +914,11 @@ int manager_get_session_by_pid(Manager *m, pid_t pid, Session **session) {
a4b143
         int r;
a4b143
 
a4b143
         assert(m);
a4b143
-        assert(pid >= 1);
a4b143
         assert(session);
a4b143
 
a4b143
+        if (pid < 1)
a4b143
+                return -EINVAL;
a4b143
+
a4b143
         r = cg_pid_get_unit(pid, &unit);
a4b143
         if (r < 0)
a4b143
                 return r;
a4b143
@@ -935,9 +937,11 @@ int manager_get_user_by_pid(Manager *m, pid_t pid, User **user) {
a4b143
         int r;
a4b143
 
a4b143
         assert(m);
a4b143
-        assert(pid >= 1);
a4b143
         assert(user);
a4b143
 
a4b143
+        if (pid < 1)
a4b143
+                return -EINVAL;
a4b143
+
a4b143
         r = cg_pid_get_slice(pid, &unit);
a4b143
         if (r < 0)
a4b143
                 return r;