Package: squid3 / 3.4.8-6+deb8u5

44-SQUID-2016_11-CVE-2016-10002.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
------------------------------------------------------------
revno: 13242
revision-id: squid3@treenet.co.nz-20161216125323-xz36cyeya39lxcux
parent: squid3@treenet.co.nz-20161216120519-10g7sfp18rckdr11
fixes bug: http://bugs.squid-cache.org/show_bug.cgi?id=3379
author: Garri Djavadyan <garryd@comnet.uz>, Amos Jeffries <squid3@treenet.co.nz>
committer: Amos Jeffries <squid3@treenet.co.nz>
branch nick: 3.4
timestamp: Sat 2016-12-17 01:53:23 +1300
message:
  Bug 3379: Combination of If-Match and a Cache Hit result in TCP Connection Failure
------------------------------------------------------------
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: squid3@treenet.co.nz-20161216125323-xz36cyeya39lxcux
# target_branch: http://bzr.squid-cache.org/bzr/squid3/3.4
# testament_sha1: 94c6075d46a6962cf6e177797b6ba7719260d600
# timestamp: 2016-12-16 13:50:59 +0000
# source_branch: http://bzr.squid-cache.org/bzr/squid3/3.4
# base_revision_id: squid3@treenet.co.nz-20161216120519-\
#   10g7sfp18rckdr11
# 
# Begin patch
=== modified file 'src/client_side_reply.cc'
--- a/src/client_side_reply.cc	2014-09-15 08:15:59 +0000
+++ b/src/client_side_reply.cc	2016-12-16 12:53:23 +0000
@@ -545,6 +545,7 @@
        ) {
         http->logType = LOG_TCP_NEGATIVE_HIT;
         sendMoreData(result);
+        return;
     } else if (!http->flags.internal && refreshCheckHTTP(e, r)) {
         debugs(88, 5, "clientCacheHit: in refreshCheck() block");
         /*
@@ -591,25 +592,29 @@
             http->logType = LOG_TCP_MISS;
             processMiss();
         }
-    } else if (r->conditional())
-        processConditional(result);
-    else {
-        /*
-         * plain ol' cache hit
-         */
+        return;
+    } else if (r->conditional()) {
+        debugs(88, 5, "conditional HIT");
+        if (processConditional(result))
+            return;
+    }
+
+    /*
+     * plain ol' cache hit
+     */
+    debugs(88, 5, "plain old HIT");
 
 #if USE_DELAY_POOLS
-        if (e->store_status != STORE_OK)
-            http->logType = LOG_TCP_MISS;
-        else
+    if (e->store_status != STORE_OK)
+        http->logType = LOG_TCP_MISS;
+    else
 #endif
-            if (e->mem_status == IN_MEMORY)
-                http->logType = LOG_TCP_MEM_HIT;
-            else if (Config.onoff.offline)
-                http->logType = LOG_TCP_OFFLINE_HIT;
+        if (e->mem_status == IN_MEMORY)
+            http->logType = LOG_TCP_MEM_HIT;
+        else if (Config.onoff.offline)
+            http->logType = LOG_TCP_OFFLINE_HIT;
 
-        sendMoreData(result);
-    }
+    sendMoreData(result);
 }
 
 /**
@@ -708,17 +713,16 @@
 }
 
 /// process conditional request from client
-void
+bool
 clientReplyContext::processConditional(StoreIOBuffer &result)
 {
     StoreEntry *const e = http->storeEntry();
 
     if (e->getReply()->sline.status() != Http::scOkay) {
-        debugs(88, 4, "clientReplyContext::processConditional: Reply code " <<
-               e->getReply()->sline.status() << " != 200");
+        debugs(88, 4, "Reply code " << e->getReply()->sline.status() << " != 200");
         http->logType = LOG_TCP_MISS;
         processMiss();
-        return;
+        return true;
     }
 
     HttpRequest &r = *http->request;
@@ -726,7 +730,7 @@
     if (r.header.has(HDR_IF_MATCH) && !e->hasIfMatchEtag(r)) {
         // RFC 2616: reply with 412 Precondition Failed if If-Match did not match
         sendPreconditionFailedError();
-        return;
+        return true;
     }
 
     bool matchedIfNoneMatch = false;
@@ -739,14 +743,14 @@
             r.header.delById(HDR_IF_MODIFIED_SINCE);
             http->logType = LOG_TCP_MISS;
             sendMoreData(result);
-            return;
+            return true;
         }
 
         if (!r.flags.ims) {
             // RFC 2616: if If-None-Match matched and there is no IMS,
             // reply with 304 Not Modified or 412 Precondition Failed
             sendNotModifiedOrPreconditionFailedError();
-            return;
+            return true;
         }
 
         // otherwise check IMS below to decide if we reply with 304 or 412
@@ -758,19 +762,20 @@
         if (e->modifiedSince(&r)) {
             http->logType = LOG_TCP_IMS_HIT;
             sendMoreData(result);
-            return;
-        }
 
-        if (matchedIfNoneMatch) {
+        } else if (matchedIfNoneMatch) {
             // If-None-Match matched, reply with 304 Not Modified or
             // 412 Precondition Failed
             sendNotModifiedOrPreconditionFailedError();
-            return;
+
+        } else {
+            // otherwise reply with 304 Not Modified
+            sendNotModified();
         }
-
-        // otherwise reply with 304 Not Modified
-        sendNotModified();
+        return true;
     }
+
+    return false;
 }
 
 void

=== modified file 'src/client_side_reply.h'
--- a/src/client_side_reply.h	2014-03-09 01:48:00 +0000
+++ b/src/client_side_reply.h	2016-12-16 12:53:23 +0000
@@ -133,7 +133,7 @@
     bool alwaysAllowResponse(Http::StatusCode sline) const;
     int checkTransferDone();
     void processOnlyIfCachedMiss();
-    void processConditional(StoreIOBuffer &result);
+    bool processConditional(StoreIOBuffer &result);
     void cacheHit(StoreIOBuffer result);
     void handleIMSReply(StoreIOBuffer result);
     void sendMoreData(StoreIOBuffer result);

------------------------------------------------------------
revno: 13243
revision-id: squid3@treenet.co.nz-20161217050948-dzd44ok5ad21ylpr
parent: squid3@treenet.co.nz-20161216125323-xz36cyeya39lxcux
fixes bug: http://bugs.squid-cache.org/show_bug.cgi?id=4169
author: Garri Djavadyan <garryd@comnet.uz>
committer: Amos Jeffries <squid3@treenet.co.nz>
branch nick: 3.4
timestamp: Sat 2016-12-17 18:09:48 +1300
message:
  Bug 4169: HIT marked as MISS when If-None-Match does not match
------------------------------------------------------------
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: squid3@treenet.co.nz-20161217050948-dzd44ok5ad21ylpr
# target_branch: http://bzr.squid-cache.org/bzr/squid3/3.4
# testament_sha1: 24789f0d715d80ae93185f83db61e5dc2fe189b4
# timestamp: 2016-12-17 05:12:25 +0000
# source_branch: http://bzr.squid-cache.org/bzr/squid3/3.4
# base_revision_id: squid3@treenet.co.nz-20161216125323-\
#   xz36cyeya39lxcux
# 
# Begin patch
=== modified file 'src/LogTags.h'
--- a/src/LogTags.h	2013-02-11 23:11:12 +0000
+++ b/src/LogTags.h	2016-12-17 05:09:48 +0000
@@ -19,6 +19,7 @@
     LOG_TCP_REFRESH_MODIFIED,   // refresh from origin replaced existing entry
     LOG_TCP_CLIENT_REFRESH_MISS,
     LOG_TCP_IMS_HIT,
+    LOG_TCP_INM_HIT,
     LOG_TCP_SWAPFAIL_MISS,
     LOG_TCP_NEGATIVE_HIT,
     LOG_TCP_MEM_HIT,
@@ -44,6 +45,7 @@
     return
         (code == LOG_TCP_HIT) ||
         (code == LOG_TCP_IMS_HIT) ||
+        (code == LOG_TCP_INM_HIT) ||
         (code == LOG_TCP_REFRESH_FAIL_OLD) ||
         (code == LOG_TCP_REFRESH_UNMODIFIED) ||
         (code == LOG_TCP_NEGATIVE_HIT) ||

=== modified file 'src/client_side.cc'
--- a/src/client_side.cc	2016-05-09 13:11:21 +0000
+++ b/src/client_side.cc	2016-12-17 05:09:48 +0000
@@ -456,6 +456,7 @@
         statCounter.client_http.nearHitSvcTime.count(svc_time);
         break;
 
+    case LOG_TCP_INM_HIT:
     case LOG_TCP_IMS_HIT:
         statCounter.client_http.nearMissSvcTime.count(svc_time);
         break;

=== modified file 'src/client_side_reply.cc'
--- a/src/client_side_reply.cc	2016-12-16 12:53:23 +0000
+++ b/src/client_side_reply.cc	2016-12-17 05:09:48 +0000
@@ -733,40 +733,27 @@
         return true;
     }
 
-    bool matchedIfNoneMatch = false;
     if (r.header.has(HDR_IF_NONE_MATCH)) {
-        if (!e->hasIfNoneMatchEtag(r)) {
-            // RFC 2616: ignore IMS if If-None-Match did not match
-            r.flags.ims = false;
-            r.ims = -1;
-            r.imslen = 0;
-            r.header.delById(HDR_IF_MODIFIED_SINCE);
-            http->logType = LOG_TCP_MISS;
-            sendMoreData(result);
-            return true;
-        }
+        // RFC 7232: If-None-Match recipient MUST ignore IMS
+        r.flags.ims = false;
+        r.ims = -1;
+        r.imslen = 0;
+        r.header.delById(HDR_IF_MODIFIED_SINCE);
 
-        if (!r.flags.ims) {
-            // RFC 2616: if If-None-Match matched and there is no IMS,
-            // reply with 304 Not Modified or 412 Precondition Failed
+        if (e->hasIfNoneMatchEtag(r)) {
             sendNotModifiedOrPreconditionFailedError();
             return true;
         }
 
-        // otherwise check IMS below to decide if we reply with 304 or 412
-        matchedIfNoneMatch = true;
+        // None-Match is true (no ETag matched); treat as an unconditional hit
+        return false;
     }
 
     if (r.flags.ims) {
         // handle If-Modified-Since requests from the client
         if (e->modifiedSince(&r)) {
-            http->logType = LOG_TCP_IMS_HIT;
-            sendMoreData(result);
-
-        } else if (matchedIfNoneMatch) {
-            // If-None-Match matched, reply with 304 Not Modified or
-            // 412 Precondition Failed
-            sendNotModifiedOrPreconditionFailedError();
+            // Modified-Since is true; treat as an unconditional hit
+            return false;
 
         } else {
             // otherwise reply with 304 Not Modified
@@ -1892,7 +1879,12 @@
     StoreEntry *e = http->storeEntry();
     const time_t timestamp = e->timestamp;
     HttpReply *const temprep = e->getReply()->make304();
-    http->logType = LOG_TCP_IMS_HIT;
+    // log as TCP_INM_HIT if code 304 generated for
+    // If-None-Match request
+    if (!http->request->flags.ims)
+        http->logType = LOG_TCP_INM_HIT;
+    else
+        http->logType = LOG_TCP_IMS_HIT;
     removeClientStoreReference(&sc, http);
     createStoreEntry(http->request->method, RequestFlags());
     e = http->storeEntry();