Hi Kevin,

Kevin Koster via Bug reports and feature requests for GNU mailutils ha escrit:

> In both Mailutils 3.17 and 3.20 (Linux OS) Putmail ignores multiple
> ";to=" addresses separated by commas

Thanks for reporting.  Please apply the attached fix.

> $ echo -e 'From: [email protected]\nTo: [email protected]\nCc: 
> [email protected]\nSubject: Test\n\nTesting 1,2,3,4' | putmail 
> --debug-level=all -f "[email protected]" 
> "smtp://[email protected]:587;[email protected],[email protected]"
>  2>putmail_3.20_log.txt

Please note that it is advised to percent-encode @ in parameters, as in:

smtp://[email protected]:587;to=test%40recipient.invalid,testrecipient%40example.com

Regards,
Sergey

>From e2a67ee303d86dc87219520a66c243875aa3735f Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <[email protected]>
Date: Fri, 10 Oct 2025 10:47:05 +0300
Subject: [PATCH] Fix bug in mu_address_dup

* libmailutils/address/address.c (mu_address_dup): Duplicate entire
address structure.
---
 libmailutils/address/address.c | 85 ++++++++++++++++++++--------------
 1 file changed, 50 insertions(+), 35 deletions(-)

diff --git a/libmailutils/address/address.c b/libmailutils/address/address.c
index ca942a6a8..7353caf99 100644
--- a/libmailutils/address/address.c
+++ b/libmailutils/address/address.c
@@ -670,7 +670,7 @@ mu_address_contains_email (mu_address_t addr, const char *email)
 }

 static int
-mu_list_copy (mu_address_t dst, mu_address_t src)
+_address_copy (mu_address_t dst, mu_address_t src)
 {
   /* FIXME: How about:
     if (src->printable)
@@ -692,16 +692,46 @@ mu_list_copy (mu_address_t dst, mu_address_t src)
   return 0;
 }

+static mu_address_t
+first_address_dup (mu_address_t src)
+{
+  mu_address_t dst = calloc (1, sizeof (*dst));
+  if (dst && _address_copy (dst, src))
+    {
+      mu_address_destroy (&dst);
+      return NULL;
+    }
+  return dst;
+}
+
 mu_address_t
 mu_address_dup (mu_address_t src)
 {
-  mu_address_t dst = calloc (1, sizeof (*dst));
+  mu_address_t head = NULL, tail = NULL;

-  if (!dst)
-    return NULL;
-  if (mu_list_copy (dst, src))
-    mu_address_destroy (&dst);
-  return dst;
+  while (src)
+    {
+      mu_address_t dst = calloc (1, sizeof (*dst));
+      if (!dst)
+	{
+	  mu_address_destroy (&head);
+	  return NULL;
+	}
+
+      if (tail)
+	tail->next = dst;
+      else
+	head = dst;
+      tail = dst;
+
+      if (_address_copy (dst, src))
+	{
+	  mu_address_destroy (&head);
+	  return NULL;
+	}
+      src = src->next;
+    }
+  return head;
 }

 int
@@ -717,41 +747,26 @@ mu_address_union (mu_address_t *a, mu_address_t b)
       *a = mu_address_dup (b);
       if (!*a)
 	return ENOMEM;
-      last = *a;
-      b = b->next;
+      return 0;
     }
-  else
+
+  if ((*a)->printable)
     {
-      if ((*a)->printable)
-	{
-	  free ((*a)->printable);
-	  (*a)->printable = NULL;
-	}
-      for (last = *a; last->next; last = last->next)
-	;
+      free ((*a)->printable);
+      (*a)->printable = NULL;
     }
+  for (last = *a; last->next; last = last->next)
+    ;

   for (; b; b = b->next)
     if (!mu_address_contains_email (*a, b->email))
       {
-	if (last->email)
-	  {
-	    mu_address_t next = mu_address_dup (b);
-	    if (!next)
-	      return ENOMEM;
-	    last->next = next;
-	    last = next;
-	  }
-	else
-	  {
-	    int rc = mu_list_copy (last, b);
-	    if (rc)
-	      {
-		_address_free (last);
-		memset (last, 0, sizeof (*last));
-		return rc;
-	      }
-	  }
+	mu_address_t next = first_address_dup (b);
+	if (!next)
+	  return ENOMEM;
+	last->next = next;
+	last = next;
       }
+
   return 0;
 }
--
2.35.1

  • Putmai... Kevin Koster via Bug reports and feature requests for GNU mailutils
    • M... Sergey Poznyakoff
      • ... Sergey Poznyakoff
        • ... Kevin Koster via Bug reports and feature requests for GNU mailutils
    • R... Sergey Poznyakoff
      • ... Kevin Koster via Bug reports and feature requests for GNU mailutils
        • ... Sergey Poznyakoff
          • ... Sergey Poznyakoff
            • ... Kevin Koster via Bug reports and feature requests for GNU mailutils

Reply via email to