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