Welcome! Log In Create A New Profile

Advanced

[nginx] Image filter: large image handling.

Maxim Dounin
August 28, 2013 04:34AM
details: http://hg.nginx.org/nginx/rev/317e0893a1e6
branches:
changeset: 5348:317e0893a1e6
user: Lanshun Zhou <zls.sogou@gmail.com>
date: Wed Aug 28 00:19:07 2013 +0800
description:
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

diffstat:

src/http/modules/ngx_http_image_filter_module.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)

diffs (17 lines):

diff --git a/src/http/modules/ngx_http_image_filter_module.c b/src/http/modules/ngx_http_image_filter_module.c
--- 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 *
"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;

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Image filter: large image handling.

Maxim Dounin 1177 August 28, 2013 04:34AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 223
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready