]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Avoid infinite recursion on HTTP upgrade.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 11 Mar 2013 12:58:38 +0000 (12:58 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 11 Mar 2013 12:58:38 +0000 (12:58 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10893 7a7537e8-13f0-0310-91df-b6672ffda945

cups/http-private.h
cups/http.c

index d326a0a80e3fc569edc3993c7eb48210ced599b2..d0ea961a014c50c781a9c291377e049fb7e1afd4 100644 (file)
@@ -316,6 +316,7 @@ struct _http_s                              /**** HTTP connection structure ****/
 #  endif /* HAVE_GSSAPI */
 
   /**** New in CUPS 1.7 ****/
+  int                  tls_upgrade;    /* Non-zero if we are doing an upgrade */
   _http_mode_t         mode;           /* _HTTP_MODE_CLIENT or _HTTP_MODE_SERVER */
   char                 *accept_encoding,
                                        /* Accept-Encoding field */
index 109ff098b9cf89e5f666390c99bc2a8a53e93338..9e64f48311c3422b7b2eb79b31d81c5cc93081d6 100644 (file)
@@ -2777,7 +2777,7 @@ httpReconnect2(http_t *http,              /* I - Connection to server */
       return (-1);
     }
   }
-  else if (http->encryption == HTTP_ENCRYPTION_REQUIRED)
+  else if (http->encryption == HTTP_ENCRYPTION_REQUIRED && !http->tls_upgrade)
     return (http_upgrade(http));
 #endif /* HAVE_SSL */
 
@@ -4900,8 +4900,13 @@ http_send(http_t       *http,            /* I - Connection to server */
 
   if (http->fd < 0 || http->status == HTTP_STATUS_ERROR ||
       http->status >= HTTP_STATUS_BAD_REQUEST)
+  {
+    DEBUG_printf(("5http_send: Reconnecting, fd=%d, status=%d, tls_upgrade=%d",
+                  http->fd, http->status, http->tls_upgrade));
+
     if (httpReconnect2(http, 30000, NULL))
       return (-1);
+  }
 
  /*
   * Flush any written data that is pending...
@@ -5680,6 +5685,7 @@ http_upgrade(http_t *http)                /* I - Connection to server */
   * encryption on the link...
   */
 
+  http->tls_upgrade         = 1;
   http->field_authorization = NULL;    /* Don't free the auth string */
 
   httpClearFields(http);
@@ -5706,6 +5712,7 @@ http_upgrade(http_t *http)                /* I - Connection to server */
   http->expect              = myhttp.expect;
   http->field_authorization = myhttp.field_authorization;
   http->digest_tries        = myhttp.digest_tries;
+  http->tls_upgrade         = 0;
 
  /*
   * See if we actually went secure...