Blame SOURCES/0008-vdagentd-Better-check-for-vdagent_connection_get_pee.patch

ad412c
From 64289e71a1b2a9dc6868eb810cf93ca8c0644693 Mon Sep 17 00:00:00 2001
ad412c
From: Frediano Ziglio <freddy77@gmail.com>
ad412c
Date: Mon, 21 Sep 2020 16:42:26 +0100
ad412c
Subject: [PATCH vd_agent_linux 08/17] vdagentd: Better check for
ad412c
 vdagent_connection_get_peer_pid results
ad412c
MIME-Version: 1.0
ad412c
Content-Type: text/plain; charset=UTF-8
ad412c
Content-Transfer-Encoding: 8bit
ad412c
ad412c
The function can return -1 and leave "err" to NULL in some cases,
ad412c
do not check only for "err".
ad412c
ad412c
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
ad412c
Acked-by: Julien Ropé <jrope@redhat.com>
ad412c
---
ad412c
 src/vdagentd/vdagentd.c | 12 ++++++++----
ad412c
 1 file changed, 8 insertions(+), 4 deletions(-)
ad412c
ad412c
diff --git a/src/vdagentd/vdagentd.c b/src/vdagentd/vdagentd.c
ad412c
index 94b8681..12cbbd0 100644
ad412c
--- a/src/vdagentd/vdagentd.c
ad412c
+++ b/src/vdagentd/vdagentd.c
ad412c
@@ -933,10 +933,14 @@ static void agent_connect(UdscsConnection *conn)
ad412c
 
ad412c
     if (session_info) {
ad412c
         pid = vdagent_connection_get_peer_pid(VDAGENT_CONNECTION(conn), &err;;
ad412c
-        if (err) {
ad412c
-            syslog(LOG_ERR, "Could not get peer PID, disconnecting new client: %s",
ad412c
-                            err->message);
ad412c
-            g_error_free(err);
ad412c
+        if (err || pid <= 0) {
ad412c
+            static const char msg[] = "Could not get peer PID, disconnecting new client";
ad412c
+            if (err) {
ad412c
+                syslog(LOG_ERR, "%s: %s", msg, err->message);
ad412c
+                g_error_free(err);
ad412c
+            } else {
ad412c
+                syslog(LOG_ERR, "%s", msg);
ad412c
+            }
ad412c
             agent_data_destroy(agent_data);
ad412c
             udscs_server_destroy_connection(server, conn);
ad412c
             return;
ad412c
-- 
ad412c
2.26.2
ad412c