Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
albrechtd opened this issue Nov 17, 2024 · 0 comments

Comments

@albrechtd
Copy link
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant