Opened 12 years ago

Last modified 12 years ago

#256 closed defect

включение limit_rate приводит к переполнению на 32битных системах — at Version 2

Reported by: Алексей Антропов Owned by: Valentin V. Bartenev
Priority: major Milestone:
Component: nginx-core Version: 1.2.x
Keywords: Cc:
uname -a: Isilon OneFS isilon-1 v6.5.4.10
nginx -V: nginx version: nginx/1.2.4
built by gcc 4.2.1 20070719 [FreeBSD]
configure arguments: --with-pcre=pcre-8.31 --with-http_perl_module --add-module=nginx_mod_h264_streaming-2.2.8 --add-module=ngx_http_file_compose_filter_module --with-debug

Description (last modified by Valentin V. Bartenev)

При вычислении лимита отдачи в src/http/ngx_http_write_filter_module.c

limit = r->limit_rate * (ngx_time() - r->start_sec + 1)
        - (c->sent - clcf->limit_rate_after);

в 32битных системах вычисление лимита может превысить 232, заметили при limit_rate 1200k через один час отдача останавливается.

Помогает приведение типа:

--- nginx-1.2.5.orig/src/http/ngx_http_write_filter_module.c    2012-12-12 10:30:16.936031137 +0200
+++ nginx-1.2.5/src/http/ngx_http_write_filter_module.c    2012-12-12 10:35:44.253313996 +0200
@@ -207,7 +207,7 @@
     }
 
     if (r->limit_rate) {
-        limit = r->limit_rate * (ngx_time() - r->start_sec + 1)
+        limit = (off_t) r->limit_rate * (ngx_time() - r->start_sec + 1)
                 - (c->sent - clcf->limit_rate_after);
 
         if (limit <= 0) {

Change History (2)

comment:1 by maxim, 12 years ago

Owner: set to Valentin V. Bartenev
Status: newassigned

comment:2 by Valentin V. Bartenev, 12 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.