Skip to content
Snippets Groups Projects
Commit df1cd46f authored by Heinrich Schuchardt's avatar Heinrich Schuchardt Committed by Michal Simek
Browse files

arm64: zynqmp: avoid out of buffer access


strncat(a, b, c) appends a maximum of c characters plus the 0 byte
to a.

In board_init we first write 4 characters plus 0 byte to version.
So only ZYNQMP_VERSION_SIZE - 5 additional characters fit into
version.

The problem was indicated by cppcheck.

Signed-off-by: default avatarHeinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
parent 74ba69db
No related branches found
No related tags found
No related merge requests found
...@@ -172,10 +172,10 @@ int board_init(void) ...@@ -172,10 +172,10 @@ int board_init(void)
if (current_el() != 3) { if (current_el() != 3) {
static char version[ZYNQMP_VERSION_SIZE]; static char version[ZYNQMP_VERSION_SIZE];
strncat(version, "xczu", ZYNQMP_VERSION_SIZE); strncat(version, "xczu", 4);
zynqmppl.name = strncat(version, zynqmppl.name = strncat(version,
zynqmp_get_silicon_idcode_name(), zynqmp_get_silicon_idcode_name(),
ZYNQMP_VERSION_SIZE); ZYNQMP_VERSION_SIZE - 5);
printf("Chip ID:\t%s\n", zynqmppl.name); printf("Chip ID:\t%s\n", zynqmppl.name);
fpga_init(); fpga_init();
fpga_add(fpga_xilinx, &zynqmppl); fpga_add(fpga_xilinx, &zynqmppl);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment