-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Open
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillacheck-requestRequest for a new check in clang-tidyRequest for a new check in clang-tidyclang-tidygood first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contribute
Description
Bugzilla Link | 41166 |
Version | unspecified |
OS | All |
Extended Description
It's a common idiom to have a fixed-size buffer of characters allocated on the stack and then to printf into the buffer. Create a check that recommends that the counted versions of functions are used, e.g. prefer snprintf over sprintf.
Example:
void f()
{
char buff[80];
sprintf(buff, "Hello, %s!\n", "world");
}
Becomes:
void f()
{
char buff[80];
snprintf(buff, sizeof(buff), "Hello, %s!\n", "world");
}
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillacheck-requestRequest for a new check in clang-tidyRequest for a new check in clang-tidyclang-tidygood first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contribute