Monday's patch left dbmail-smtp with a segfault for any delivery besides
"normal" due to not checking if normal was selected before calling
mail_adr_list() and passing a NULL for the first option. This patch adds a
test to make sure that "normal" has been selected before the function call.

Incidentally, mail_adr_list() should probably do some input validation so as
not to crash even if called with NULL arguments... I'll work up a patch for
that this evening.

Ilja, would it be easier if I started posting patches to SourceForge again?

Aaron
--- dbmail-2.0rc1-fixes/main.c	2004-02-10 01:46:35.000000000 -0800
+++ dbmail-2.0rc2-fixes/main.c	2004-02-11 10:45:42.000000000 -0800
@@ -217,26 +217,30 @@
           if (returnpath.total_nodes == 0)
               trace(TRACE_DEBUG, "main(): no return path found.");
 
-  /* parse for destination addresses */
-  trace(TRACE_DEBUG, "main(): scanning for [%s]",
-        deliver_to_header);
-  if (mail_adr_list(deliver_to_header, &users, &mimelist) !=0)
-      trace(TRACE_STOP, "main(): scanner found no email addresses (scanned for %s)", 
-            deliver_to_header);
-
-  /* Loop through the users list, moving the entries into the dsnusers list. */
-  for(tmp = list_getstart(&users); tmp != NULL; tmp = tmp->nextnode)
+  /* If the NORMAL delivery mode has been selected... */
+  if (deliver_to_header)
     {
-      deliver_to_user_t dsnuser;
-      char *tmpaddr;
-
-      tmpaddr = (char *)tmp->data;
-
-      dsnuser_init(&dsnuser);
-      dsnuser.address = tmpaddr;
-
-      list_nodeadd(&dsnusers, &dsnuser, sizeof(deliver_to_user_t));
-            
+      /* parse for destination addresses */
+      trace(TRACE_DEBUG, "main(): scanning for [%s]",
+            deliver_to_header);
+      if (mail_adr_list(deliver_to_header, &users, &mimelist) !=0)
+          trace(TRACE_STOP, "main(): scanner found no email addresses (scanned for %s)", 
+                deliver_to_header);
+  
+      /* Loop through the users list, moving the entries into the dsnusers list. */
+      for(tmp = list_getstart(&users); tmp != NULL; tmp = tmp->nextnode)
+        {
+          deliver_to_user_t dsnuser;
+          char *tmpaddr;
+  
+          tmpaddr = (char *)tmp->data;
+  
+          dsnuser_init(&dsnuser);
+          dsnuser.address = tmpaddr;
+  
+          list_nodeadd(&dsnusers, &dsnuser, sizeof(deliver_to_user_t));
+                
+        }
     }
 
   /* inserting messages into the database */

Reply via email to