Skip to content

[clang-tidy] Check request: bugprone-avoid-invalid-format-string #131936

@denzor200

Description

@denzor200

Needs a check that will find incorrect format strings and point them out. This check will not provide fix-it hints.

int number = 42;
printf("Value: %s\n", number);             // BAD - expected string but an integer was passed
printf("Numbers: %d, %d\n", 42);           // BAD - wrong number of arguments
printf("String: %.*s\n", "Hello world");   // BAD - %.*s requires two arguments
const char* user_input = get_user_input();
printf(user_input);                        // BAD - format string vulnerability
printf("Numbers: %d, %d\n", 100, 200);     // OK
constexpr const char* no_user_input = get_format();
printf(no_user_input);                     // OK

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions