From 78b7f37a1ae30dd85f7b13492bbe402a591fae60 Mon Sep 17 00:00:00 2001 From: Mike Holmes Date: Thu, 3 Dec 2015 13:49:57 -0500 Subject: helper: fix strncpy in table support Fixes Bug 1905 - CID 154167: Calling strncpy with a maximum size argument of ODP_TABLE_NAME_LEN bytes on destination array tbl->name of size ODP_TABLE_NAME_LEN bytes might leave the destination string unterminated if the copied string is also of the maximum size ODP_TABLE_NAME_LEN. Make the copy leave one char for the null terminator. Signed-off-by: Mike Holmes Reviewed-by: Bill Fischofer Signed-off-by: Maxim Uvarov --- helper/hashtable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'helper/hashtable.c') diff --git a/helper/hashtable.c b/helper/hashtable.c index 1121beb0c..e0f562e5c 100644 --- a/helper/hashtable.c +++ b/helper/hashtable.c @@ -92,7 +92,7 @@ odph_table_t odph_hash_table_create(const char *name, uint32_t capacity, memset(tbl, 0, capacity << 20); tbl->init_cap = capacity << 20; - strncpy(tbl->name, name, ODPH_TABLE_NAME_LEN); + strncpy(tbl->name, name, ODPH_TABLE_NAME_LEN - 1); tbl->key_size = key_size; tbl->value_size = value_size; -- cgit v1.2.3