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

Annotate cfg_error with format attribute #164

Merged
merged 1 commit into from
Apr 24, 2023

Conversation

cgzones
Copy link
Contributor

@cgzones cgzones commented Sep 22, 2022

Format attributes help compilers to warn on format string misuses, like:

cfg_error(cfg, user_defined_input)  // potential security issue
cfg_error(cfg, "foo %d", "bar")


confuse.c:1246:20: warning: format string is not a string literal [-Wformat-nonliteral]
                vfprintf(stderr, fmt, ap);
                                 ^~~

Guard the annotation with __GNUC__, defined by GCC and Clang, which support the GNU extension of function format attributes.

TODO: Untested on Windows.

Format attributes help compilers to warn on format string misuses, like:

    cfg_error(cfg, user_defined_input)  // potential security issue
    cfg_error(cfg, "foo %d", "bar")

    confuse.c:1246:20: warning: format string is not a string literal [-Wformat-nonliteral]
                    vfprintf(stderr, fmt, ap);
                                     ^~~

Guard the annotation with __GNUC__, defined by GCC and Clang, which
support the GNU extension of function format attributes.
@troglobit
Copy link
Collaborator

LGTM

@cgzones cgzones marked this pull request as ready for review January 7, 2023 15:44
@cgzones
Copy link
Contributor Author

cgzones commented Apr 23, 2023

Kindly ping.

@troglobit troglobit merged commit 16d69b3 into libconfuse:master Apr 24, 2023
@cgzones cgzones deleted the format branch April 28, 2023 14:56
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

Successfully merging this pull request may close these issues.

None yet

2 participants