xref: /btstack/tool/misc/replace_sprintf.cocci (revision 884d3c56f3c839726594fcf182a0e2d13048dadf)
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