~ubuntu-branches/ubuntu/jaunty/cups/jaunty

« back to all changes in this revision

Viewing changes to debian/patches/client-ssl-hang.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2009-01-13 17:03:55 UTC
  • Revision ID: james.westby@ubuntu.com-20090113170355-4v39tht77h3w4to0
Tags: 1.3.8-1lenny4.1
* Non-maintainer upload.
* Apply upstream patch to fix client request loop for large request over
  SSL. (closes: #506702)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh /usr/share/dpatch/dpatch-run
 
2
##
 
3
## DP: Fix client loop for SSL connections.
 
4
 
 
5
--- a/scheduler/client.c        (revision 7820)
 
6
+++ b/scheduler/client.c        (working copy)
 
7
@@ -28,6 +28,7 @@
 
8
  *   cupsdUpdateCGI()        - Read status messages from CGI scripts and programs.
 
9
  *   cupsdWriteClient()      - Write data to a client as needed.
 
10
  *   check_if_modified()     - Decode an "If-Modified-Since" line.
 
11
+ *   data_ready()            - Check whether data is available from a client.
 
12
  *   encrypt_client()        - Enable encryption for the client...
 
13
  *   get_cdsa_certificate()  - Convert a keychain name into the CFArrayRef
 
14
  *                            required by SSLSetCertificate.
 
15
@@ -83,6 +84,7 @@
 
16
 
 
17
 static int             check_if_modified(cupsd_client_t *con,
 
18
                                          struct stat *filestats);
 
19
+static int             data_ready(cupsd_client_t *con);
 
20
 #ifdef HAVE_SSL
 
21
 static int             encrypt_client(cupsd_client_t *con);
 
22
 #endif /* HAVE_SSL */
 
23
@@ -989,8 +991,7 @@
 
24
        */
 
25
 
 
26
         while ((status = httpUpdate(HTTP(con))) == HTTP_CONTINUE)
 
27
-         if (con->http.used == 0 ||
 
28
-             !memchr(con->http.buffer, '\n', con->http.used))
 
29
+         if (!data_ready(con))
 
30
            break;
 
31
 
 
32
        if (status != HTTP_OK && status != HTTP_CONTINUE)
 
33
@@ -1889,7 +1890,7 @@
 
34
            }
 
35
          }
 
36
         }
 
37
-       while (con->http.state == HTTP_PUT_RECV && con->http.used > 0);
 
38
+       while (con->http.state == HTTP_PUT_RECV && data_ready(con));
 
39
 
 
40
         if (con->http.state == HTTP_WAITING)
 
41
        {
 
42
@@ -2064,7 +2065,7 @@
 
43
            }
 
44
          }
 
45
         }
 
46
-       while (con->http.state == HTTP_POST_RECV && con->http.used > 0);
 
47
+       while (con->http.state == HTTP_POST_RECV && data_ready(con));
 
48
 
 
49
        if (con->http.state == HTTP_POST_SEND)
 
50
        {
 
51
@@ -2914,7 +2915,39 @@
 
52
 }
 
53
 
 
54
 
 
55
+/*
 
56
+ * 'data_ready()' - Check whether data is available from a client.
 
57
+ */
 
58
+
 
59
+static int                             /* O - 1 if data is ready, 0 otherwise */
 
60
+data_ready(cupsd_client_t *con)                /* I - Client */
 
61
+{
 
62
+  if (con->http.used > 0)
 
63
+    return (1);
 
64
 #ifdef HAVE_SSL
 
65
+  else if (con->http.tls)
 
66
+  {
 
67
+#  ifdef HAVE_LIBSSL
 
68
+    if (SSL_pending((SSL *)(con->http.tls)))
 
69
+      return (1);
 
70
+#  elif defined(HAVE_GNUTLS)
 
71
+    if (gnutls_record_check_pending(((http_tls_t *)(con->http.tls))->session))
 
72
+      return (1);
 
73
+#  elif defined(HAVE_CDSASSL)
 
74
+    size_t bytes;                      /* Bytes that are available */
 
75
+
 
76
+    if (!SSLGetBufferedReadSize(((http_tls_t *)(con->http.tls))->session,
 
77
+                                &bytes) && bytes > 0)
 
78
+      return (1);
 
79
+#  endif /* HAVE_LIBSSL */
 
80
+  }
 
81
+#endif /* HAVE_SSL */
 
82
+
 
83
+  return (0);
 
84
+}
 
85
+
 
86
+
 
87
+#ifdef HAVE_SSL
 
88
 /*
 
89
  * 'encrypt_client()' - Enable encryption for the client...
 
90
  */