mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-01 00:28:18 +00:00
tool/misc: replace sprintf with snprintf and zero last byte using coccinelle
This commit is contained in:
parent
ae46d66684
commit
924c007898
8
tool/misc/replace_sprintf.cocci
Normal file
8
tool/misc/replace_sprintf.cocci
Normal file
@ -0,0 +1,8 @@
|
||||
// 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;
|
Loading…
Reference in New Issue
Block a user