Skip to content

Commit

Permalink
linux-gen: dpdk: fix char array size in dpdk_pktio_init()
Browse files Browse the repository at this point in the history
Reserve space for an extra character in mem_str[] so that sprintf()
can print the null character there, even though we don't actually need
it. Buffer overrun reported by GCC address sanitizer.

Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Reviewed-by: Matias Elo <matias.elo@nokia.com>
  • Loading branch information
JereLeppanen authored and MatiasElo committed Apr 12, 2024
1 parent 70c1728 commit 3d92357
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion platform/linux-generic/pktio/dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ static int dpdk_pktio_init(void)
if (numa_nodes <= 0)
numa_nodes = 1;

char mem_str[mem_str_len * numa_nodes];
char mem_str[mem_str_len * numa_nodes + 1];

for (i = 0; i < numa_nodes; i++)
sprintf(&mem_str[i * mem_str_len], "%d,", DPDK_MEMORY_MB);
Expand Down

0 comments on commit 3d92357

Please sign in to comment.