]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fixed chunking infinite loop condition.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 22 Oct 1999 20:00:32 +0000 (20:00 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 22 Oct 1999 20:00:32 +0000 (20:00 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@743 7a7537e8-13f0-0310-91df-b6672ffda945

cups/http.c

index 12d98f18c45228f33eb6236630c2c8ccdb876d41..858357b944bd9b589d0ff67481adab8397e96d0b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: http.c,v 1.54 1999/10/21 18:34:14 mike Exp $"
+ * "$Id: http.c,v 1.55 1999/10/22 20:00:32 mike Exp $"
  *
  *   HTTP routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -790,9 +790,31 @@ httpWrite(http_t     *http,                /* I - HTTP data */
   if (http->data_encoding == HTTP_ENCODE_CHUNKED &&
       (http->state == HTTP_GET_SEND || http->state == HTTP_POST_RECV ||
        http->state == HTTP_POST_SEND || http->state == HTTP_PUT_RECV))
+  {
     if (httpPrintf(http, "%x\r\n", length) < 0)
       return (-1);
 
+    if (length == 0)
+    {
+     /*
+      * A zero-length chunk ends a transfer; unless we are sending POST
+      * data, go idle...
+      */
+
+      DEBUG_puts("httpWrite: changing states...");
+
+      if (http->state == HTTP_POST_RECV)
+       http->state ++;
+      else
+       http->state = HTTP_WAITING;
+
+      if (httpPrintf(http, "\r\n") < 0)
+       return (-1);
+
+      return (0);
+    }
+  }
+
   tbytes = 0;
 
   while (length > 0)
@@ -818,13 +840,14 @@ httpWrite(http_t     *http,               /* I - HTTP data */
     if (httpPrintf(http, "\r\n") < 0)
       return (-1);
 
-  if ((http->data_remaining == 0 && http->data_encoding == HTTP_ENCODE_LENGTH) ||
-      length == 0)
+  if (http->data_remaining == 0 && http->data_encoding == HTTP_ENCODE_LENGTH)
   {
    /*
     * Finished with the transfer; unless we are sending POST data, go idle...
     */
 
+    DEBUG_puts("httpWrite: changing states...");
+
     if (http->state == HTTP_POST_RECV)
       http->state ++;
     else
@@ -1479,5 +1502,5 @@ http_send(http_t       *http,     /* I - HTTP data */
 
 
 /*
- * End of "$Id: http.c,v 1.54 1999/10/21 18:34:14 mike Exp $".
+ * End of "$Id: http.c,v 1.55 1999/10/22 20:00:32 mike Exp $".
  */