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