Skip to content

API change of g_mime_parser_options_set_warning_callback() can result in undefined behaviourΒ #172

@albrechtd

Description

@albrechtd

Commit f50f3bd added an extra parameter to function g_mime_parser_options_set_warning_callback() which requires all applications using this function to be modified and re-compiled, which is quite unexpected for a minor version update. Just updating the shared library from ver. 3.2.13 to 3.2.14 or later, i.e. calling the function with the wrong number of arguments, according to ISO/IEC 9899:2011, section 6.5.2.2 Function calls, clause 6

[…] If the number of arguments does not equal the number of parameters, the behavior is undefined.

may result in strange effects, including crashes (it appears that gcc implicitly sets the missing parameter to NULL, but this is an extension of the aforementioned standard). See also e.g. SEI CERT C Coding Standard, EXP37-C or MISRA C:2012 Rule 8.2.

Suggestion:

  • add a new function g_mime_parser_options_set_warning_callback_full() with 4 parameters, and
  • revert the change of g_mime_parser_options_set_warning_callback(), making it a wrapper to the former with an extra 4th NULL parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions