From 2810b934647edd483996bee1f5f9256a162b2705 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 16 Feb 2024 16:24:26 +0900 Subject: [PATCH] dirmngr: Fix keep-alive flag handling. * dirmngr/http.c (run_proxy_connect): Set KEEP_ALIVE if not Basic Authentication. Fix resource leak of FP_WRITE. -- GnuPG-bug-id: 6997 Signed-off-by: NIIBE Yutaka --- dirmngr/http.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dirmngr/http.c b/dirmngr/http.c index ac7e13241..e4c719348 100644 --- a/dirmngr/http.c +++ b/dirmngr/http.c @@ -2553,7 +2553,7 @@ run_proxy_connect (http_t hd, proxy_info_t proxy, * RFC-4559 - SPNEGO-based Kerberos and NTLM HTTP Authentication */ auth_basic = !!proxy->uri->auth; - hd->keep_alive = 0; + hd->keep_alive = !auth_basic; /* We may need to send more requests. */ /* For basic authentication we need to send just one request. */ if (auth_basic @@ -2717,6 +2717,14 @@ run_proxy_connect (http_t hd, proxy_info_t proxy, } leave: + if (hd->keep_alive) + { + es_fclose (hd->fp_write); + hd->fp_write = NULL; + /* The close has released the cookie and thus we better set it + * to NULL. */ + hd->write_cookie = NULL; + } /* Restore flags, destroy stream, reset state. */ hd->flags = saved_flags; es_fclose (hd->fp_read);