Skip to content

Commit

Permalink
helper: test: table: fix buffer overflow
Browse files Browse the repository at this point in the history
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 <fan.hong@arm.com>
  • Loading branch information
FanHong674 committed Dec 5, 2023
1 parent 5efd07b commit 9e02a25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion helper/hashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions helper/test/table.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9e02a25

Please sign in to comment.