fix handling of pre-parsing address errors
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Mon, 18 Oct 1993 04:00:35 +0000 (20:00 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Mon, 18 Oct 1993 04:00:35 +0000 (20:00 -0800)
SCCS-vsn: usr.sbin/sendmail/src/parseaddr.c 8.13
SCCS-vsn: usr.sbin/sendmail/src/savemail.c 8.15
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 8.34

usr/src/usr.sbin/sendmail/src/deliver.c
usr/src/usr.sbin/sendmail/src/parseaddr.c
usr/src/usr.sbin/sendmail/src/savemail.c

index df60829..4de3c99 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)deliver.c  8.33 (Berkeley) %G%";
+static char sccsid[] = "@(#)deliver.c  8.34 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -993,6 +993,7 @@ tryhost:
                        if (p == curhost)
                        {
                                syserr("deliver: null host name in signature");
                        if (p == curhost)
                        {
                                syserr("deliver: null host name in signature");
+                               curhost++;
                                continue;
                        }
                        strncpy(hostbuf, curhost, p - curhost);
                                continue;
                        }
                        strncpy(hostbuf, curhost, p - curhost);
index a94c23b..68a32f4 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)parseaddr.c        8.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)parseaddr.c        8.13 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -84,13 +84,6 @@ parseaddr(addr, a, flags, delim, delimptr, e)
        if (tTd(20, 1))
                printf("\n--parseaddr(%s)\n", addr);
 
        if (tTd(20, 1))
                printf("\n--parseaddr(%s)\n", addr);
 
-       if (invalidaddr(addr))
-       {
-               if (tTd(20, 1))
-                       printf("parseaddr-->bad address\n");
-               return NULL;
-       }
-
        {
                extern char *DelimChar;         /* parseaddr.c */
                char savec;
        {
                extern char *DelimChar;         /* parseaddr.c */
                char savec;
@@ -118,6 +111,13 @@ parseaddr(addr, a, flags, delim, delimptr, e)
                return (NULL);
        }
 
                return (NULL);
        }
 
+       if (invalidaddr(addr, delim == '\0' ? NULL : *delimptr))
+       {
+               if (tTd(20, 1))
+                       printf("parseaddr-->bad address\n");
+               return NULL;
+       }
+
        /*
        **  Save addr if we are going to have to.
        **
        /*
        **  Save addr if we are going to have to.
        **
@@ -204,18 +204,36 @@ parseaddr(addr, a, flags, delim, delimptr, e)
 */
 
 bool
 */
 
 bool
-invalidaddr(addr)
+invalidaddr(addr, delimptr)
        register char *addr;
        register char *addr;
+       char *delimptr;
 {
 {
-       for (; *addr != '\0'; addr++)
+       char savedelim;
+
+       if (delimptr != NULL)
+               savedelim = *delimptr;
+#if 0
+       /* for testing.... */
+       if (strcmp(addr, "INvalidADDR") == 0)
        {
        {
-               if ((*addr & 0340) != 0200)
-                       continue;
-               setstat(EX_USAGE);
-               usrerr("553 Address contained invalid control characters");
+               usrerr("553 INvalid ADDRess");
+               if (delimptr != NULL)
+                       *delimptr = savedelim;
                return TRUE;
        }
                return TRUE;
        }
-       return FALSE;
+#endif
+       for (; *addr != '\0'; addr++)
+       {
+               if ((*addr & 0340) == 0200)
+                       break;
+       }
+       if (delimptr != NULL)
+               *delimptr = savedelim;
+       if (*addr == '\0')
+               return FALSE;
+       setstat(EX_USAGE);
+       usrerr("553 Address contained invalid control characters");
+       return TRUE;
 }
 \f/*
 **  ALLOCADDR -- do local allocations of address on demand.
 }
 \f/*
 **  ALLOCADDR -- do local allocations of address on demand.
index 71d1f8f..fdee712 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)savemail.c 8.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)savemail.c 8.15 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -70,8 +70,6 @@ savemail(e)
                return;
        }
 
                return;
        }
 
-       e->e_flags &= ~EF_FATALERRS;
-
        /*
        **  In the unhappy event we don't know who to return the mail
        **  to, make someone up.
        /*
        **  In the unhappy event we don't know who to return the mail
        **  to, make someone up.
@@ -574,7 +572,7 @@ errbody(fp, m, e)
        for (q = e->e_parent->e_sendqueue; q != NULL; q = q->q_next)
                if (bitset(QBADADDR, q->q_flags))
                        break;
        for (q = e->e_parent->e_sendqueue; q != NULL; q = q->q_next)
                if (bitset(QBADADDR, q->q_flags))
                        break;
-       if (q == NULL)
+       if (q == NULL && !bitset(EF_FATALERRS, e->e_parent->e_flags))
        {
                putline("    **********************************************",
                        fp, m);
        {
                putline("    **********************************************",
                        fp, m);