<div dir="ltr"><p dir="ltr">It's ok for me, thanks~</p>
<div class="gmail_quote">ÔÚ 2013-8-28 ÉÏÎç6:43£¬"Maxim Dounin" <<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>>дµÀ£º<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hello!<br>
<br>
On Wed, Aug 28, 2013 at 12:21:27AM +0800, lanshun zhou wrote:<br>
<br>
> # HG changeset patch<br>
> # User Lanshun Zhou <<a href="mailto:zls.sogou@gmail.com" target="_blank">zls.sogou@gmail.com</a>><br>
> # Date 1377620347 -28800<br>
> # Node ID 4fae04f332b489c85cdc116e6138a618372d3691<br>
> # Parent  d1403de4163100ec0c6c015e57f22384456870e3<br>
> Image filter: large image handling.<br>
><br>
> If Content-Length header is not set, and the image size is larger than the<br>
> buffer size, client will hang until a timeout occurs.<br>
><br>
> Now NGX_HTTP_UNSUPPORTED_MEDIA_TYPE is returned immediately.<br>
><br>
> diff -r d1403de41631 -r 4fae04f332b4<br>
> src/http/modules/ngx_http_image_filter_module.c<br>
> --- a/src/http/modules/ngx_http_image_filter_module.c   Tue Aug 27 17:37:15<br>
> 2013 +0400<br>
> +++ b/src/http/modules/ngx_http_image_filter_module.c   Wed Aug 28 00:19:07<br>
> 2013 +0800<br>
> @@ -478,7 +478,14 @@<br>
>                         "image buf: %uz", size);<br>
><br>
>          rest = ctx->image + ctx->length - p;<br>
> -        size = (rest < size) ? rest : size;<br>
> +        if (rest < size) {<br>
> +            ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,<br>
> +                          "image filter: too big response: >%z, "<br>
> +                          "try to increase image_filter_buffer",<br>
> +                          ctx->length);<br>
> +<br>
> +            return NGX_ERROR;<br>
> +        }<br>
<br>
Good catch, thnx.<br>
<br>
I don't think the message should be different from one emitted with<br>
Content-Length available though.  What about something like this:<br>
<br>
--- a/src/http/modules/ngx_http_image_filter_module.c<br>
+++ b/src/http/modules/ngx_http_image_filter_module.c<br>
@@ -478,7 +478,12 @@ ngx_http_image_read(ngx_http_request_t<br>
                        "image buf: %uz", size);<br>
<br>
         rest = ctx->image + ctx->length - p;<br>
-        size = (rest < size) ? rest : size;<br>
+<br>
+        if (size > rest) {<br>
+            ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,<br>
+                          "image filter: too big response");<br>
+            return NGX_ERROR;<br>
+        }<br>
<br>
         p = ngx_cpymem(p, b->pos, size);<br>
         b->pos += size;<br>
<br>
<br>
?<br>
<br>
--<br>
Maxim Dounin<br>
<a href="http://nginx.org/en/donation.html" target="_blank">http://nginx.org/en/donation.html</a><br>
<br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org" target="_blank">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br>
</blockquote></div>
</div>