btstack/tool/misc/replace_sprintf.cocci

9 lines
246 B
Plaintext

// Replace sprintf with snprintf and assert trailing '\0'
@@
expression buffer, formatstring;
expression list args;
@@
- sprintf(buffer, formatstring, args);
+ snprintf(buffer, sizeof(buffer), formatstring, args);
+ buffer[sizeof(buffer)-1] = 0;