http: fix http header table hash keys leak 37/43337/2
authorMatus Fabian <[email protected]>
Fri, 27 Jun 2025 11:40:51 +0000 (13:40 +0200)
committerFlorin Coras <[email protected]>
Tue, 1 Jul 2025 22:09:57 +0000 (22:09 +0000)
Type: fix

Change-Id: I60ebf767a1f96a1290b7738d6859241739ce452c
Signed-off-by: Matus Fabian <[email protected]>
src/plugins/http/http.h

index 95b2faf..5777bd5 100644 (file)
@@ -723,11 +723,16 @@ always_inline void
 http_reset_header_table (http_header_table_t *ht)
 {
   int i;
+  hash_pair_t *p;
   for (i = 0; i < vec_len (ht->concatenated_values); i++)
     vec_free (ht->concatenated_values[i]);
   vec_reset_length (ht->concatenated_values);
   vec_reset_length (ht->values);
   vec_reset_length (ht->buf);
+  hash_foreach_pair (p, ht->value_by_name, ({
+                      void *k = uword_to_pointer (p->key, void *);
+                      clib_mem_free (k);
+                    }));
   hash_free (ht->value_by_name);
 }
 
@@ -751,11 +756,16 @@ always_inline void
 http_free_header_table (http_header_table_t *ht)
 {
   int i;
+  hash_pair_t *p;
   for (i = 0; i < vec_len (ht->concatenated_values); i++)
     vec_free (ht->concatenated_values[i]);
   vec_free (ht->concatenated_values);
   vec_free (ht->values);
   vec_free (ht->buf);
+  hash_foreach_pair (p, ht->value_by_name, ({
+                      void *k = uword_to_pointer (p->key, void *);
+                      clib_mem_free (k);
+                    }));
   hash_free (ht->value_by_name);
 }