On Thursday, August 7, 2003, at 06:01 PM, Charles Sprickman wrote:
It looks like the Delivered-To problem has returned:

Delivered-To: [EMAIL PROTECTED]

I wasn't seeing this under 5.3.21...

I assume this is with a catchall... Here's a patch to address that problem. I'm also considering going through all of the code that writes a Delivered-To header, and changing it to use this routine. vdelivermail uses multiple methods of building that header, and I'm not sure if all cases work properly.


--- vpopmail-5.3.24/vdelivermail.c      Sun Aug  3 08:02:14 2003
+++ vpopmail-5.3.25/vdelivermail.c      Fri Aug  8 13:24:31 2003
@@ -567,27 +566,44 @@
     /* must be an email address */
     } else {
       char *dtline;
-      char *tstr;
+      char *atpos;
+      int dtlen;
 
-        qmail_inject_open(address);
-        write_fd = fdm;
-        inject = 1;
+      qmail_inject_open(address);
+      write_fd = fdm;
+      inject = 1;
 
-        /* use the DTLINE variable, but skip past the dash in 
-         * [EMAIL PROTECTED] 
-         */
+      /* use the DTLINE variable, but skip past the dash in 
+       * [EMAIL PROTECTED] 
+       */
 
-        if ( (dtline = getenv("DTLINE")) != NULL ) {
-            while (*dtline!=0 && *dtline!=':' ) ++dtline;
-            while (*dtline!=0 && *dtline!='-' ) ++dtline;
-            if ( *dtline != 0 ) ++dtline;
-                for(tstr=dtline;*tstr!=0;++tstr) if (*tstr=='\n') *tstr=0;
-            } else {
-                if (*address=='&') ++address;
-                dtline = address;
-            }
-            snprintf(DeliveredTo, sizeof(DeliveredTo), 
-                "%sDelivered-To: %s\n", getenv("RPLINE"), dtline);
+      if ( (dtline = getenv("DTLINE")) != NULL ) {
+        dtlen = strlen(dtline);
+        /* make sure dtline is at least as long as "Delivered-To: " */
+        if (dtlen < 15) {
+          dtline = NULL;
+        } else {
+          dtline += 14;  /* skip "Delivered-To: " */
+          dtlen -= 14;
+          atpos = strchr (dtline, '@');
+          /* ex: dtline = "[EMAIL PROTECTED]"
+           * dtlen = 25, atpos = dtline+14
+           * add 25 - 14 - 1 = 10 bytes to dtline,
+           * now points to "[EMAIL PROTECTED]".
+           */
+          if (atpos != NULL) {
+            dtline += (dtlen - (atpos - dtline) - 1);
+          }
+        }
+      }
+      if (dtline == NULL) {
+        if (*address=='&') ++address;  /* will this case ever happen? */
+        snprintf(DeliveredTo, sizeof(DeliveredTo), 
+          "%sDelivered-To: %s\n", getenv("RPLINE"), address);
+      } else {
+        snprintf(DeliveredTo, sizeof(DeliveredTo), 
+          "%sDelivered-To: %s", getenv("RPLINE"), dtline);
+      }
     }
 
 #ifdef MAKE_SEEKABLE



Note that this patch also addresses a problem the old method had with domain names containing "-".

I'll be placing the patch on SourceForge, and adding it to the next vpopmail release. Please provide feedback -- it's done well with limited testing on my development box.

It works by skipping the 14-character "Delivered-To: " part of the header as qmail sets it. It converts the trailing newline to a

--
Tom Collins
[EMAIL PROTECTED]
http://sniffter.com/ - info on the Sniffter hand-held Network Tester

Reply via email to