提交 2bdb42f7 编写于 作者: H Heinrich Schuchardt 提交者: Lukasz Majewski

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: NHeinrich Schuchardt <xypron.glpk@gmx.de>
上级 071f369d
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册