Menu

#12 Using dkim_options can leak memory

v2.8.2
closed-fixed
5
2009-06-01
2009-04-23
No

The function dkim_options, when used with DKIM_OPTS_SKIPHDRS or DKIM_OPTS_SIGNHDRS, can produce a memory leak. For example:

dkim_options(dkim_lib, DKIM_OP_SETOPT, DKIM_OPTS_SKIPHDRS, dkim_skip_headers, sizeof(char **));

Later, after calling dkim_close(), memory is not freed. The problem appears to be that dkim_options compiles regex's using regcomp() without later freeing them. If you call the following before dkim_close(), the memory is freed:

dkim_options(dkim_lib, DKIM_OP_SETOPT, DKIM_OPTS_SKIPHDRS, NULL, sizeof(char **));

This is because dkim_options with a NULL ptr value calls regfree(). The attached patch calls regfree() during dkim_close() on any regexes that were compiled for DKIM_OPTS_SKIPHDRS or DKIM_OPTS_SIGNHDRS.

Discussion

  • Heath Morrison

    Heath Morrison - 2009-04-23

    Calls regfree() on regular expressions allocated by dkim_options()

     
  • Heath Morrison

    Heath Morrison - 2009-04-23
    • labels: --> Functionality
    • priority: 5 --> 6
    • milestone: --> v2.8.2
     
  • Anonymous

    Anonymous - 2009-04-23
    • assigned_to: nobody --> sm-msk
     
  • Anonymous

    Anonymous - 2009-04-23

    Thanks for the patch!

    This had already been discovered during an internal code audit, but the patched code has not yet been released.

    I note you've upped the priority from the default. Are you in need of a patched release soon?

     
  • Heath Morrison

    Heath Morrison - 2009-04-23

    Thanks for your prompt response!

    No, I don't need an immediate patched release. Thank you for caring, though :) I've patched my own release and can continue quite fine without an official release.

     
  • Heath Morrison

    Heath Morrison - 2009-04-23
    • priority: 6 --> 5
     
  • Anonymous

    Anonymous - 2009-06-01

    v2.8.3 released, containing this fix.

     
  • Anonymous

    Anonymous - 2009-06-01
    • status: open --> closed-fixed
     

Log in to post a comment.