Skip to content

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

@albrechtd

Description

@albrechtd
Contributor

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.

Activity

jstedfast

jstedfast commented on Apr 4, 2025

@jstedfast
Owner

The problem I'm going to have is that I no longer have a Linux or Mac machine, so not sure how I can make a release :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jstedfast@albrechtd

        Issue actions

          API change of g_mime_parser_options_set_warning_callback() can result in undefined behaviour · Issue #172 · jstedfast/gmime