tool/misc: replace sprintf with snprintf and zero last byte using coccinelle

This commit is contained in:
Matthias Ringwald 2021-03-30 15:51:40 +02:00
parent ae46d66684
commit 924c007898

View 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;