diff options
author | Lanshun Zhou <zls.sogou@gmail.com> | 2013-08-28 00:19:07 +0800 |
---|---|---|
committer | Lanshun Zhou <zls.sogou@gmail.com> | 2013-08-28 00:19:07 +0800 |
commit | be23dcb1a1d80742a95521939021e3adb9d9796b (patch) | |
tree | 13bd62f8bd4e3bdd6ec03765bd30f9953a0432ae | |
parent | 51f7761710fb797be1f3c401be2aa57b603ce45d (diff) | |
download | nginx-be23dcb1a1d80742a95521939021e3adb9d9796b.tar.gz nginx-be23dcb1a1d80742a95521939021e3adb9d9796b.zip |
Image filter: large image handling.
If Content-Length header is not set, and the image size is larger than the
buffer size, client will hang until a timeout occurs.
Now NGX_HTTP_UNSUPPORTED_MEDIA_TYPE is returned immediately.
diff -r d1403de41631 -r 4fae04f332b4
src/http/modules/ngx_http_image_filter_module.c
-rw-r--r-- | src/http/modules/ngx_http_image_filter_module.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/http/modules/ngx_http_image_filter_module.c b/src/http/modules/ngx_http_image_filter_module.c index 6d3f47dcb..cc41ef0d5 100644 --- a/src/http/modules/ngx_http_image_filter_module.c +++ b/src/http/modules/ngx_http_image_filter_module.c @@ -478,7 +478,12 @@ ngx_http_image_read(ngx_http_request_t *r, ngx_chain_t *in) "image buf: %uz", size); rest = ctx->image + ctx->length - p; - size = (rest < size) ? rest : size; + + if (size > rest) { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + "image filter: too big response"); + return NGX_ERROR; + } p = ngx_cpymem(p, b->pos, size); b->pos += size; |