early ngx_memcpy() with NGX_MEMCPY_LIMIT patch

Vladimir Shebordaev vshebordaev at mail.ru
Mon Jul 30 18:24:49 UTC 2012


Hi,

ngx_memcpy() is invoked before ngx_cycle has been initialized, so the server
can segfault there when NGX_MEMCPY_LIMIT is enabled.

diff -Naur rev4754/src/core/ngx_string.c ticket55/src/core/ngx_string.c
--- rev4754/src/core/ngx_string.c       2012-07-16 23:15:16.613980918 +0400
+++ ticket55/src/core/ngx_string.c      2012-07-23 15:41:02.863561192 +0400
@@ -1830,7 +1830,8 @@
 ngx_memcpy(void *dst, void *src, size_t n)
 {
     if (n > NGX_MEMCPY_LIMIT) {
-        ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "memcpy %uz bytes", n);
+        if (ngx_cycle)
+           ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "memcpy
%uz bytes", n);
         ngx_debug_point();
     }


--
Regards,
Vladimir



More information about the nginx-devel mailing list