xref: /btstack/tool/misc/replace_sprintf.cocci (revision f11fd9a990fedbf11b7c70e38b9da44019506e13)
1// Replace sprintf with snprintf and assert trailing '\0'
2@@
3expression buffer, formatstring;
4expression list args;
5@@
6- sprintf(buffer, formatstring, args);
7+ snprintf(buffer, sizeof(buffer), formatstring, args);
8+ buffer[sizeof(buffer)-1] = 0;
9