RHEL-31887 cups doesn't send Content-Type header back to client when Set-Cookie is seen first

Resolves: RHEL-31887
This commit is contained in:
Zdenek Dohnal 2024-04-05 13:18:35 +02:00
parent 79b3f18c92
commit c3bcd6355a
2 changed files with 72 additions and 1 deletions

View File

@ -0,0 +1,64 @@
From d60341b3355fd8825bec00792f301ef99d715a93 Mon Sep 17 00:00:00 2001
From: Zdenek Dohnal <zdohnal@redhat.com>
Date: Wed, 3 Apr 2024 10:39:24 +0200
Subject: [PATCH] scheduler: Fix sending response headers to client
Sometimes headers are not correctly copied into response to the client
(some are missing). It happens because `sent_header` is set prematurely
before the actual send happens. The present code in affected `cupsdWriteClient`
scope looks like code remains from CUPS 1.6.3.
With the change, testing via curl gives reliable results all time.
---
scheduler/client.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/scheduler/client.c b/scheduler/client.c
index 62ac21c69..e7e312b8e 100644
--- a/scheduler/client.c
+++ b/scheduler/client.c
@@ -2400,23 +2400,12 @@ cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */
httpSetField(con->http, field, value);
if (field == HTTP_FIELD_LOCATION)
- {
con->pipe_status = HTTP_STATUS_SEE_OTHER;
- con->sent_header = 2;
- }
- else
- con->sent_header = 1;
}
else if (!_cups_strcasecmp(con->header, "Status") && value)
- {
con->pipe_status = (http_status_t)atoi(value);
- con->sent_header = 2;
- }
else if (!_cups_strcasecmp(con->header, "Set-Cookie") && value)
- {
httpSetCookie(con->http, value);
- con->sent_header = 1;
- }
}
/*
@@ -2451,6 +2440,8 @@ cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */
cupsdCloseClient(con);
return;
}
+
+ con->sent_header = 1;
}
else
{
@@ -2459,6 +2450,8 @@ cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */
cupsdCloseClient(con);
return;
}
+
+ con->sent_header = 1;
}
}
else
--
2.44.0

View File

@ -22,7 +22,7 @@ Summary: CUPS printing system
Name: cups Name: cups
Epoch: 1 Epoch: 1
Version: 2.4.7 Version: 2.4.7
Release: 9%{?dist} Release: 10%{?dist}
# backend/failover.c - BSD-3-Clause # backend/failover.c - BSD-3-Clause
# cups/md5* - Zlib # cups/md5* - Zlib
# scheduler/colorman.c - Apache-2.0 WITH LLVM-exception AND BSD-2-Clause # scheduler/colorman.c - Apache-2.0 WITH LLVM-exception AND BSD-2-Clause
@ -93,6 +93,8 @@ Patch1002: cups-colorman-leak.patch
Patch1003: cups-unload-job-leak.patch Patch1003: cups-unload-job-leak.patch
# https://github.com/OpenPrinting/cups/pull/839 # https://github.com/OpenPrinting/cups/pull/839
Patch1004: 0001-httpAddrConnect2-Check-for-error-if-POLLHUP-is-in-va.patch Patch1004: 0001-httpAddrConnect2-Check-for-error-if-POLLHUP-is-in-va.patch
# https://github.com/OpenPrinting/cups/pull/927
Patch1005: 0001-scheduler-Fix-sending-response-headers-to-client.patch
##### Patches removed because IMHO they aren't no longer needed ##### Patches removed because IMHO they aren't no longer needed
@ -334,6 +336,8 @@ to CUPS daemon. This solution will substitute printer drivers and raw queues in
%patch -P 1003 -p1 -b .unloadjob %patch -P 1003 -p1 -b .unloadjob
# https://github.com/OpenPrinting/cups/pull/839 # https://github.com/OpenPrinting/cups/pull/839
%patch -P 1004 -p1 -b .httpaddrconnect-pollhup %patch -P 1004 -p1 -b .httpaddrconnect-pollhup
# https://github.com/OpenPrinting/cups/pull/927
%patch -P 1005 -p1 -b .sent-headers
%if %{lspp} %if %{lspp}
@ -808,6 +812,9 @@ rm -f %{cups_serverbin}/backend/smb
%{_mandir}/man7/ippeveps.7.gz %{_mandir}/man7/ippeveps.7.gz
%changelog %changelog
* Fri Apr 05 2024 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.4.7-10
- RHEL-31887 cups doesn't send Content-Type header back to client when Set-Cookie is seen first
* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1:2.4.7-9 * Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1:2.4.7-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild