]>
Commit | Line | Data |
---|---|---|
992dce4c MW |
1 | Index: squid/src/HttpReply.c |
2 | diff -c squid/src/HttpReply.c:1.49 squid/src/HttpReply.c:1.49.2.1 | |
3 | *** squid/src/HttpReply.c:1.49 Wed Oct 24 02:19:08 2001 | |
4 | --- squid/src/HttpReply.c Tue May 6 14:13:02 2003 | |
5 | *************** | |
6 | *** 82,88 **** | |
7 | { | |
8 | assert(rep); | |
9 | rep->hdr_sz = 0; | |
10 | - rep->maxBodySize = 0; | |
11 | rep->pstate = psReadyToParseStartLine; | |
12 | httpBodyInit(&rep->body); | |
13 | httpHeaderInit(&rep->header, hoReply); | |
14 | --- 82,87 ---- | |
15 | *************** | |
16 | *** 463,491 **** | |
17 | else if (reply->sline.status < HTTP_OK) | |
18 | return 0; | |
19 | return reply->content_length; | |
20 | - } | |
21 | - | |
22 | - /* | |
23 | - * Calculates the maximum size allowed for an HTTP response | |
24 | - */ | |
25 | - void | |
26 | - httpReplyBodyBuildSize(request_t * request, HttpReply * reply, dlink_list * bodylist) | |
27 | - { | |
28 | - body_size *bs; | |
29 | - aclCheck_t *checklist; | |
30 | - bs = (body_size *) bodylist->head; | |
31 | - while (bs) { | |
32 | - checklist = aclChecklistCreate(bs->access_list, request, NULL); | |
33 | - checklist->reply = reply; | |
34 | - if (1 != aclCheckFast(bs->access_list, checklist)) { | |
35 | - /* deny - skip this entry */ | |
36 | - bs = (body_size *) bs->node.next; | |
37 | - } else { | |
38 | - /* Allow - use this entry */ | |
39 | - reply->maxBodySize = bs->maxsize; | |
40 | - bs = NULL; | |
41 | - debug(58, 3) ("httpReplyBodyBuildSize: Setting maxBodySize to %ld\n", (long int) reply->maxBodySize); | |
42 | - } | |
43 | - aclChecklistFree(checklist); | |
44 | - } | |
45 | } | |
46 | --- 462,465 ---- | |
47 | Index: squid/src/client_side.c | |
48 | diff -c squid/src/client_side.c:1.561.2.33 squid/src/client_side.c:1.561.2.34 | |
49 | *** squid/src/client_side.c:1.561.2.33 Wed Feb 19 16:39:12 2003 | |
50 | --- squid/src/client_side.c Tue May 6 14:13:02 2003 | |
51 | *************** | |
52 | *** 124,130 **** | |
53 | static int clientCheckContentLength(request_t * r); | |
54 | static DEFER httpAcceptDefer; | |
55 | static log_type clientProcessRequest2(clientHttpRequest * http); | |
56 | ! static int clientReplyBodyTooLarge(HttpReply *, ssize_t clen); | |
57 | static int clientRequestBodyTooLarge(int clen); | |
58 | static void clientProcessBody(ConnStateData * conn); | |
59 | ||
60 | --- 124,130 ---- | |
61 | static int clientCheckContentLength(request_t * r); | |
62 | static DEFER httpAcceptDefer; | |
63 | static log_type clientProcessRequest2(clientHttpRequest * http); | |
64 | ! static int clientReplyBodyTooLarge(clientHttpRequest *, ssize_t clen); | |
65 | static int clientRequestBodyTooLarge(int clen); | |
66 | static void clientProcessBody(ConnStateData * conn); | |
67 | ||
68 | *************** | |
69 | *** 1806,1819 **** | |
70 | return i->debt_size > 0; | |
71 | } | |
72 | ||
73 | static int | |
74 | ! clientReplyBodyTooLarge(HttpReply * rep, ssize_t clen) | |
75 | { | |
76 | ! if (0 == rep->maxBodySize) | |
77 | return 0; /* disabled */ | |
78 | if (clen < 0) | |
79 | return 0; /* unknown */ | |
80 | ! if (clen > rep->maxBodySize) | |
81 | return 1; /* too large */ | |
82 | return 0; | |
83 | } | |
84 | --- 1806,1844 ---- | |
85 | return i->debt_size > 0; | |
86 | } | |
87 | ||
88 | + /* | |
89 | + * Calculates the maximum size allowed for an HTTP response | |
90 | + */ | |
91 | + static void | |
92 | + clientMaxBodySize(request_t * request, clientHttpRequest * http, HttpReply * reply) | |
93 | + { | |
94 | + body_size *bs; | |
95 | + aclCheck_t *checklist; | |
96 | + bs = (body_size *) Config.ReplyBodySize.head; | |
97 | + while (bs) { | |
98 | + checklist = clientAclChecklistCreate(bs->access_list, http); | |
99 | + checklist->reply = reply; | |
100 | + if (1 != aclCheckFast(bs->access_list, checklist)) { | |
101 | + /* deny - skip this entry */ | |
102 | + bs = (body_size *) bs->node.next; | |
103 | + } else { | |
104 | + /* Allow - use this entry */ | |
105 | + http->maxBodySize = bs->maxsize; | |
106 | + bs = NULL; | |
107 | + debug(58, 3) ("httpReplyBodyBuildSize: Setting maxBodySize to %ld\n", (long int) http->maxBodySize); | |
108 | + } | |
109 | + aclChecklistFree(checklist); | |
110 | + } | |
111 | + } | |
112 | + | |
113 | static int | |
114 | ! clientReplyBodyTooLarge(clientHttpRequest * http, ssize_t clen) | |
115 | { | |
116 | ! if (0 == http->maxBodySize) | |
117 | return 0; /* disabled */ | |
118 | if (clen < 0) | |
119 | return 0; /* unknown */ | |
120 | ! if (clen > http->maxBodySize) | |
121 | return 1; /* too large */ | |
122 | return 0; | |
123 | } | |
124 | *************** | |
125 | *** 1857,1863 **** | |
126 | } | |
127 | } | |
128 | ||
129 | - | |
130 | /* | |
131 | * accepts chunk of a http message in buf, parses prefix, filters headers and | |
132 | * such, writes processed message to the client's socket | |
133 | --- 1882,1887 ---- | |
134 | *************** | |
135 | *** 1918,1925 **** | |
136 | if (rep) { | |
137 | aclCheck_t *ch; | |
138 | int rv; | |
139 | ! httpReplyBodyBuildSize(http->request, rep, &Config.ReplyBodySize); | |
140 | ! if (clientReplyBodyTooLarge(rep, rep->content_length)) { | |
141 | ErrorState *err = errorCon(ERR_TOO_BIG, HTTP_FORBIDDEN); | |
142 | err->request = requestLink(http->request); | |
143 | storeUnregister(http->sc, http->entry, http); | |
144 | --- 1942,1949 ---- | |
145 | if (rep) { | |
146 | aclCheck_t *ch; | |
147 | int rv; | |
148 | ! clientMaxBodySize(http->request, http, rep); | |
149 | ! if (clientReplyBodyTooLarge(http, rep->content_length)) { | |
150 | ErrorState *err = errorCon(ERR_TOO_BIG, HTTP_FORBIDDEN); | |
151 | err->request = requestLink(http->request); | |
152 | storeUnregister(http->sc, http->entry, http); | |
153 | *************** | |
154 | *** 2172,2178 **** | |
155 | } else { | |
156 | comm_close(fd); | |
157 | } | |
158 | ! } else if (clientReplyBodyTooLarge(entry->mem_obj->reply, http->out.offset)) { | |
159 | comm_close(fd); | |
160 | } else { | |
161 | /* More data will be coming from primary server; register with | |
162 | --- 2196,2203 ---- | |
163 | } else { | |
164 | comm_close(fd); | |
165 | } | |
166 | ! } else if (clientReplyBodyTooLarge(http, http->out.offset - 4096)) { | |
167 | ! /* 4096 is a margin for the HTTP headers included in out.offset */ | |
168 | comm_close(fd); | |
169 | } else { | |
170 | /* More data will be coming from primary server; register with | |
171 | Index: squid/src/protos.h | |
172 | diff -c squid/src/protos.h:1.420.2.17 squid/src/protos.h:1.420.2.18 | |
173 | *** squid/src/protos.h:1.420.2.17 Thu Jan 2 16:10:46 2003 | |
174 | --- squid/src/protos.h Tue May 6 14:13:02 2003 | |
175 | *************** | |
176 | *** 509,515 **** | |
177 | extern int httpReplyHasCc(const HttpReply * rep, http_hdr_cc_type type); | |
178 | extern void httpRedirectReply(HttpReply *, http_status, const char *); | |
179 | extern int httpReplyBodySize(method_t, HttpReply *); | |
180 | - extern void httpReplyBodyBuildSize(request_t *, HttpReply *, dlink_list *); | |
181 | ||
182 | /* Http Request */ | |
183 | extern request_t *requestCreate(method_t, protocol_t, const char *urlpath); | |
184 | --- 509,514 ---- | |
185 | Index: squid/src/structs.h | |
186 | diff -c squid/src/structs.h:1.408.2.9 squid/src/structs.h:1.408.2.10 | |
187 | *** squid/src/structs.h:1.408.2.9 Mon Jan 20 17:06:39 2003 | |
188 | --- squid/src/structs.h Tue May 6 14:13:03 2003 | |
189 | *************** | |
190 | *** 959,965 **** | |
191 | HttpStatusLine sline; | |
192 | HttpHeader header; | |
193 | HttpBody body; /* for small constant memory-resident text bodies only */ | |
194 | - size_t maxBodySize; | |
195 | }; | |
196 | ||
197 | struct _http_state_flags { | |
198 | --- 959,964 ---- | |
199 | *************** | |
200 | *** 1083,1088 **** | |
201 | --- 1082,1088 ---- | |
202 | char *location; | |
203 | } redirect; | |
204 | dlink_node active; | |
205 | + size_t maxBodySize; | |
206 | }; | |
207 | ||
208 | struct _ConnStateData { |