proposed solution for ticket 686 (With some condition, ngx_palloc() function will alloc a illegal memory address)

Chris Newton cnewton at netflix.com
Thu Dec 10 16:17:01 UTC 2020


Ticket 686 is marked as 'wontfix' as the constraints on the size of the
memory pool are documented.

I'd like to suggest that the constraints are enforced by the code to
prevent issues. eg.,

*--- a/src/core/ngx_palloc.c*

*+++ b/src/core/ngx_palloc.c*

@@ -20,6 +20,12 @@ ngx_create_pool(size_t size, ngx_log_t *log)

 {

     ngx_pool_t  *p;



+    if (size < NGX_MIN_POOL_SIZE)

+        size = NGX_MIN_POOL_SIZE;

+

+    if (size % NGX_POOL_ALIGNMENT != 0)

+        size = ngx_align(size, NGX_POOL_ALIGNMENT);

+

     p = ngx_memalign(NGX_POOL_ALIGNMENT, size, log);

     if (p == NULL) {

         return NULL;

TIA

Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20201210/4292faed/attachment.htm>


More information about the nginx-devel mailing list