]> git.pld-linux.org Git - packages/cups.git/blame - cups-1.1.18-str75.patchv2
- conflicts with ghostscript < 7.05.4 (i.e. non-espgs)
[packages/cups.git] / cups-1.1.18-str75.patchv2
CommitLineData
3f5ac2c0 1diff -ur cups-1.1.18/cups/http.c cups-1.1.18.patched/cups/http.c
2--- cups-1.1.18/cups/http.c Tue Dec 17 13:56:42 2002
3+++ cups-1.1.18.patched/cups/http.c Mon May 12 16:41:26 2003
4@@ -29,6 +29,7 @@
5 * default HTTP proxy (if any).
6 * httpCheck() - Check to see if there is a pending response from
7 * the server.
8+ * httpWait() - Wait for data available on a connection.
9 * httpClose() - Close an HTTP connection...
10 * httpConnect() - Connect to a HTTP server.
11 * httpConnectEncrypt() - Connect to a HTTP server using encryption.
12@@ -240,6 +241,18 @@
13 int /* O - 0 = no data, 1 = data available */
14 httpCheck(http_t *http) /* I - HTTP connection */
15 {
16+ return (httpWait(http, 0));
17+}
18+
19+
20+/*
21+ * 'httpWait()' - Wait for data available on a connection.
22+ */
23+
24+int /* O - 0 = no data, 1 = data available */
25+httpWait(http_t *http, /* I - HTTP connection */
26+ int msec) /* I - Milliseconds to wait */
27+{
28 fd_set input; /* Input set for select() */
29 struct timeval timeout; /* Timeout */
30
31@@ -254,6 +267,14 @@
32 if (http->used)
33 return (1);
34
35+#ifdef HAVE_LIBSSL
36+ if (http->tls)
37+ {
38+ if (SSL_pending((SSL *)(http->tls)))
39+ return (1);
40+ }
41+#endif /* HAVE_LIBSSL */
42+
43 /*
44 * Then try doing a select() to poll the socket...
45 */
46@@ -261,10 +282,15 @@
47 FD_ZERO(&input);
48 FD_SET(http->fd, &input);
49
50- timeout.tv_sec = 0;
51- timeout.tv_usec = 0;
52+ if (msec >= 0)
53+ {
54+ timeout.tv_sec = msec / 1000;
55+ timeout.tv_usec = (msec % 1000) * 1000;
56
57- return (select(http->fd + 1, &input, NULL, NULL, &timeout) > 0);
58+ return (select(http->fd + 1, &input, NULL, NULL, &timeout) > 0);
59+ }
60+ else
61+ return (select(http->fd + 1, &input, NULL, NULL, NULL) > 0);
62 }
63
64
65@@ -857,7 +883,10 @@
66 char buffer[8192]; /* Junk buffer */
67
68
69- while (httpRead(http, buffer, sizeof(buffer)) > 0);
70+ if (http->state != HTTP_WAITING)
71+ {
72+ while (httpRead(http, buffer, sizeof(buffer)) > 0);
73+ }
74 }
75
76
77@@ -931,6 +960,9 @@
78 * Buffer small reads for better performance...
79 */
80
81+ if (!http->blocking && !httpWait(http, 1000))
82+ return (0);
83+
84 if (http->data_remaining > sizeof(http->buffer))
85 bytes = sizeof(http->buffer);
86 else
87@@ -967,7 +999,10 @@
88 #endif /* WIN32 */
89 }
90 else
91+ {
92+ http->error = EPIPE;
93 return (0);
94+ }
95 }
96
97 if (http->used > 0)
98@@ -987,10 +1022,18 @@
99 }
100 #ifdef HAVE_LIBSSL
101 else if (http->tls)
102+ {
103+ if (!http->blocking && !httpWait(http, 1000))
104+ return (0);
105+
106 bytes = SSL_read((SSL *)(http->tls), buffer, length);
107+ }
108 #endif /* HAVE_LIBSSL */
109 else
110 {
111+ if (!http->blocking && !httpWait(http, 1000))
112+ return (0);
113+
114 DEBUG_printf(("httpRead: reading %d bytes from socket...\n", length));
115 bytes = recv(http->fd, buffer, length, 0);
116 DEBUG_printf(("httpRead: read %d bytes from socket...\n", bytes));
117@@ -1009,6 +1052,11 @@
118 http->error = errno;
119 #endif /* WIN32 */
120 }
121+ else
122+ {
123+ http->error = EPIPE;
124+ return (0);
125+ }
126
127 if (http->data_remaining == 0)
128 {
129@@ -1247,13 +1295,16 @@
130 * No newline; see if there is more data to be read...
131 */
132
133+ if (!http->blocking && !httpWait(http, 1000))
134+ return (NULL);
135+
136 #ifdef HAVE_LIBSSL
137 if (http->tls)
138 bytes = SSL_read((SSL *)(http->tls), bufend,
139 HTTP_MAX_BUFFER - http->used);
140 else
141 #endif /* HAVE_LIBSSL */
142- bytes = recv(http->fd, bufend, HTTP_MAX_BUFFER - http->used, 0);
143+ bytes = recv(http->fd, bufend, HTTP_MAX_BUFFER - http->used, 0);
144
145 if (bytes < 0)
146 {
147@@ -1285,8 +1336,7 @@
148 }
149 else if (bytes == 0)
150 {
151- if (http->blocking)
152- http->error = EPIPE;
153+ http->error = EPIPE;
154
155 return (NULL);
156 }
157@@ -1554,6 +1604,7 @@
158 case HTTP_POST_RECV :
159 case HTTP_PUT :
160 http->state ++;
161+ case HTTP_POST_SEND :
162 break;
163
164 default :
165diff -ur cups-1.1.18/cups/http.h cups-1.1.18.patched/cups/http.h
166--- cups-1.1.18/cups/http.h Tue Dec 17 13:56:42 2002
167+++ cups-1.1.18.patched/cups/http.h Fri May 9 13:59:10 2003
168@@ -338,6 +338,9 @@
169 char [33]);
170 extern char *httpMD5String(const md5_byte_t *, char [33]);
171
172+/**** New in CUPS 1.1.19 ****/
173+extern int httpWait(http_t *http, int msec);
174+
175
176 /*
177 * C++ magic...
178diff -ur cups-1.1.18/cups/ipp.c cups-1.1.18.patched/cups/ipp.c
179--- cups-1.1.18/cups/ipp.c Tue Dec 17 13:56:42 2002
180+++ cups-1.1.18.patched/cups/ipp.c Fri May 9 14:08:44 2003
181@@ -2036,7 +2036,14 @@
182 if (http->data_remaining == 0)
183 {
184 if (http->data_encoding == HTTP_ENCODE_CHUNKED)
185- httpGets(len, sizeof(len), http);
186+ {
187+ /*
188+ * Get the trailing CR LF after the chunk...
189+ */
190+
191+ if (!httpGets(len, sizeof(len), http))
192+ return (-1);
193+ }
194
195 if (http->data_encoding != HTTP_ENCODE_CHUNKED)
196 {
197diff -ur cups-1.1.18/scheduler/client.c cups-1.1.18.patched/scheduler/client.c
198--- cups-1.1.18/scheduler/client.c Tue Dec 17 14:00:14 2002
199+++ cups-1.1.18.patched/scheduler/client.c Fri May 9 14:25:52 2003
200@@ -82,6 +82,8 @@
201 client_t *con; /* New client pointer */
202 unsigned address;/* Address of client */
203 struct hostent *host; /* Host entry for address */
204+ static time_t last_dos = 0;
205+ /* Time of last DoS attack */
206
207
208 LogMessage(L_DEBUG2, "AcceptClient(%p) %d NumClients = %d",
209@@ -134,8 +136,12 @@
210
211 if (count >= MaxClientsPerHost)
212 {
213- LogMessage(L_WARN, "Possible DoS attack - more than %d clients connecting from %s!",
214- MaxClientsPerHost, Clients[i].http.hostname);
215+ if ((time(NULL) - last_dos) >= 60)
216+ {
217+ last_dos = time(NULL);
218+ LogMessage(L_WARN, "Possible DoS attack - more than %d clients connecting from %s!",
219+ MaxClientsPerHost, Clients[i].http.hostname);
220+ }
221
222 #ifdef WIN32
223 closesocket(con->http.fd);
224@@ -272,7 +278,7 @@
225 setsockopt(con->http.fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
226
227 /*
228- * Add the socket to the select() input mask.
229+ * Close this file on all execs...
230 */
231
232 fcntl(con->http.fd, F_SETFD, fcntl(con->http.fd, F_GETFD) | FD_CLOEXEC);
233@@ -1438,6 +1444,10 @@
234 }
235 }
236 }
237+ else if (con->http.state == HTTP_POST_RECV)
238+ {
239+ return (0);
240+ }
241 else if (con->http.state != HTTP_POST_SEND)
242 {
243 CloseClient(con);
244@@ -1784,6 +1794,14 @@
245 shutdown(con->http.fd, 0);
246 con->http.used = 0;
247
248+ /*
249+ * Update the activity time so that we timeout after 30 seconds rather
250+ * then the current Timeout setting (300 by default). This prevents
251+ * some DoS situations...
252+ */
253+
254+ con->http.activity = time(NULL) - Timeout + 30;
255+
256 LogMessage(L_DEBUG2, "ShutdownClient: Removing fd %d from InputSet...",
257 con->http.fd);
258
259diff -ur cups-1.1.18/test/run-stp-tests.sh cups-1.1.18.patched/test/run-stp-tests.sh
260--- cups-1.1.18/test/run-stp-tests.sh Tue Dec 17 14:00:25 2002
261+++ cups-1.1.18.patched/test/run-stp-tests.sh Fri May 9 14:18:48 2003
262@@ -142,6 +142,7 @@
263
264 cat >/tmp/$user/cupsd.conf <<EOF
265 Browsing Off
266+FileDevice Yes
267 Listen 127.0.0.1:$port
268 User $user
269 ServerRoot /tmp/$user
270 ServerRoot /tmp/$user
This page took 0.072738 seconds and 4 git commands to generate.