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