diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2019-08-15 23:54:15 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-08-20 12:20:33 -0400 |
commit | cd1db463539fdb51716ca48603c4b1b922cb5aaf (patch) | |
tree | a1a965e115ca08c5fe83fea1813e531592e352a9 | |
parent | ad49488ffb0dd6357139f74a6b88c0b51e1ac215 (diff) |
easylogo: avoid buffer overrun
Building easylogo with `HOST_TOOLS_ALL=y make tools` results in a build
warning due to a possible buffer overrun:
tools/easylogo/easylogo.c:453:4: note: ‘sprintf’ output between 7 and
262 bytes into a destination of size 256
sprintf (str, "%s, 0x%02x", app, *dataptr++);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Truncate the output to fit into the destination buffer.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
-rw-r--r-- | tools/easylogo/easylogo.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/easylogo/easylogo.c b/tools/easylogo/easylogo.c index 4ba86bf760..ed4bf203dd 100644 --- a/tools/easylogo/easylogo.c +++ b/tools/easylogo/easylogo.c @@ -450,7 +450,8 @@ int image_save_header (image_t * image, char *filename, char *varname) default: strcpy (app, str); - sprintf (str, "%s, 0x%02x", app, *dataptr++); + sprintf(str, "%.*s, 0x%02x", (int)sizeof(str) - 7, app, + *dataptr++); col++; count--; break; |