[cups.bugs] [MOD] STR #3519: cupsDoIORequest ignores HTTP_ERROR

Christer Bernérus bernerus at chalmers.se
Wed Mar 3 05:43:14 PST 2010


DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

I found this while looking for a cure for bug #3325. I get my stuff working
without the following fix, but it might be worth considering for inclusion
anyway.


The code in cupsDoIORequest in the send/response loop
which determines whether an HTTP error has occurred specifically inores
the status code HTTP_ERROR. 
HTTP_ERROR is returned, among other things, whenever the server returns
bad data, e.g. HTML code where HTTP headers are expected.
As the loop ignores HTTP_ERROR, this may cause an infinite loop or at
least bad behavior.

Side note: HTTP_ERROR is not caught by the expression 
status >= HTTP_BAD_REQUEST because the value of HTTP_ERROR is set to -1,
which causes the compiler to generate signed comparisons.

Fix:
--- request.c	(revision 9014)
+++ request.c	(working copy)
@@ -266,9 +266,10 @@
 
     DEBUG_printf(("2cupsDoIORequest: status=%d", status));
 
-    if (status >= HTTP_BAD_REQUEST &&
-	status != HTTP_UNAUTHORIZED &&
-	status != HTTP_UPGRADE_REQUIRED)
+    if (status == HTTP_ERROR ||
+        ( status >= HTTP_BAD_REQUEST &&
+	  status != HTTP_UNAUTHORIZED &&
+	  status != HTTP_UPGRADE_REQUIRED))
     {
       httpFlush(http);
       _cupsSetHTTPError(status);

       _cupsSetHTTPError(status);

Link: http://www.cups.org/str.php?L3519
Version: 1.4.2





More information about the cups-devel mailing list