From 9e02a25efb8a6a91da264ca2cae908b72477f309 Mon Sep 17 00:00:00 2001 From: Fan Hong Date: Mon, 27 Nov 2023 07:16:05 +0000 Subject: [PATCH] helper: test: table: fix buffer overflow The value_size is a fixed value, so the size of value should match value_size, otherwise a buffer overflow occurs when memcpy the value to hashnode in line 59 table.c. Signed-off-by: Fan Hong --- helper/hashtable.c | 2 +- helper/test/table.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/helper/hashtable.c b/helper/hashtable.c index 28c23a58c82..4aa0c3f8bf6 100644 --- a/helper/hashtable.c +++ b/helper/hashtable.c @@ -36,7 +36,7 @@ typedef struct odph_hash_node { * Its length is key_size + value_size, * suppose key_size = m; value_size = n; * its structure is like: - * k_byte1 k_byte2...k_byten v_byte1...v_bytem + * k_byte1 k_byte2...k_bytem v_byte1...v_byten */ char content[]; } odph_hash_node; diff --git a/helper/test/table.c b/helper/test/table.c index fb17e8a3701..bb333609d24 100644 --- a/helper/test/table.c +++ b/helper/test/table.c @@ -32,10 +32,10 @@ int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED) char ip_addr1[] = "12345678"; char ip_addr2[] = "11223344"; char ip_addr3[] = "55667788"; - char mac_addr1[] = "0A1122334401"; - char mac_addr2[] = "0A1122334402"; - char mac_addr3[] = "0B4433221101"; - char mac_addr4[] = "0B4433221102"; + char mac_addr1[16] = "0A1122334401"; + char mac_addr2[16] = "0A1122334402"; + char mac_addr3[16] = "0B4433221101"; + char mac_addr4[16] = "0B4433221102"; ret = odp_init_global(&instance, NULL, NULL); if (ret != 0) {