httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 51696] New: Code clean up (remove a 1024 heap allocated buffer)
Date Sat, 20 Aug 2011 06:33:48 GMT

             Bug #: 51696
           Summary: Code clean up (remove a 1024 heap allocated buffer)
           Product: Apache httpd-2
           Version: 2.3-HEAD
          Platform: PC
        OS/Version: Windows 2000
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: mod_usertrack
    Classification: Unclassified

Created attachment 27414
Proposed patch


in 'modules/metadata/mod_usertrack.c', the function 'make_cookie' can be

Actually, it uses a hard coded 1024 bytes buffer that is heap allocated. At the
end of the function, this buffer is copied into a pool with a 'apr_pstrdup'
call when doing the final 'apr_table_setn' call.
So, if the buffer was directly allocated within the pool, we could get reed of
the intermediate buffer.

What this patch actually does is :
   - remove the 'cookiebuf' buffer
   - allocate 'cookiebuf' directly in the pool with calling 'apr_psprintf'
instead of 'apr_snprintf'
   - turns a 'apr_psprintf(r->pool, "%s=%s...)' call to an equivalent 
'apr_pstrcat' call which is faster (1)
   - move this before 'if (cls->expires)' because the same allocation is done
in the 2 paths of the 'if' (1)
   - avoid calling 'apr_pstrdup' when setting 'cookiebuf' in the table as it is
now already allocated in the right location.

(1) : this part is unrelated to the removal of the buffer, but was already
proposed, accepted but never applied.
See for that.

Finally, this patch is *not* tested and is proposed as-is, as I'm not able to
compile httpd for now on my machine.

Best regards,
Christophe JAILLET

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message