From 39601309eb3e5e88a1c1fbda9a272ba8691f1bf3 Mon Sep 17 00:00:00 2001
From: Jan Rybar <jrybar@redhat.com>
Date: Wed, 13 May 2026 14:58:32 +0200
Subject: [PATCH] Draining loop can keep polkit busy

The draining loop is not really appropriate for pipe input, especially
in a daemon.

Co-authored-by: Frantisek Sumsal <fsumsal@redhat.com>

CVE: CVE-2026-4897
Upstream-Status: Backport [https://github.com/polkit-org/polkit/commit/39601309eb3e5e88a1c1fbda9a272ba8691f1bf3]
Signed-off-by: Peter Marko <peter.marko@siemens.com>
---
 src/polkitagent/polkitagenthelperprivate.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/src/polkitagent/polkitagenthelperprivate.c b/src/polkitagent/polkitagenthelperprivate.c
index 7e4f94e..c0a9825 100644
--- a/src/polkitagent/polkitagenthelperprivate.c
+++ b/src/polkitagent/polkitagenthelperprivate.c
@@ -70,10 +70,6 @@ read_cookie (int argc, char **argv)
         }
       if (buf[strlen (buf) - 1] != '\n')
         {
-          /* Cookie too long - drain remaining input and reject */
-          int c;
-          while ((c = getchar ()) != '\n' && c != EOF)
-            ;
           errno = EOVERFLOW;
           return NULL;
         }
