commit 4dd9c48: [Fix] Fix iteration over milter headers

Vsevolod Stakhov vsevolod at rspamd.com
Tue Aug 23 21:28:03 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-08-23 22:26:40 +0100
URL: https://github.com/rspamd/rspamd/commit/4dd9c4833430e7eba51e1f11e10dd6644e969000 (HEAD -> master)

[Fix] Fix iteration over milter headers
Issue: #4246

---
 src/libserver/milter.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/libserver/milter.c b/src/libserver/milter.c
index 7b6fa78ea..a84506720 100644
--- a/src/libserver/milter.c
+++ b/src/libserver/milter.c
@@ -1784,10 +1784,11 @@ rspamd_milter_process_milter_block (struct rspamd_milter_session *session,
 				ucl_object_iter_t *elt_it;
 
 				elt_it = ucl_object_iterate_new (cur);
+				const char *key_name = ucl_object_key (cur);
 
-				while ((cur_elt = ucl_object_iterate_safe (elt_it, true)) != NULL) {
+				while ((cur_elt = ucl_object_iterate_safe (elt_it, false)) != NULL) {
 					if (ucl_object_type (cur_elt) == UCL_STRING) {
-						hname = g_string_new (ucl_object_key (cur));
+						hname = g_string_new (key_name);
 						hvalue = g_string_new (ucl_object_tostring (cur_elt));
 
 						rspamd_milter_send_action (session,
@@ -1798,7 +1799,7 @@ rspamd_milter_process_milter_block (struct rspamd_milter_session *session,
 					}
 					else if (ucl_object_type (cur_elt) == UCL_OBJECT) {
 						rspamd_milter_extract_single_header (session,
-								ucl_object_key (cur), cur_elt);
+								key_name, cur_elt);
 					}
 					else if (ucl_object_type (cur_elt) == UCL_ARRAY) {
 						/* Multiple values for the same key */
@@ -1810,7 +1811,7 @@ rspamd_milter_process_milter_block (struct rspamd_milter_session *session,
 						while ((array_elt = ucl_object_iterate_safe (array_it,
 								true)) != NULL) {
 							rspamd_milter_extract_single_header (session,
-									ucl_object_key (cur), array_elt);
+									key_name, array_elt);
 						}
 
 						ucl_object_iterate_free (array_it);


More information about the Commits mailing list