fix a variety of bugs found by Eric Wassenaar <e07@nikhef.nl>
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sat, 20 Feb 1993 01:21:32 +0000 (17:21 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sat, 20 Feb 1993 01:21:32 +0000 (17:21 -0800)
SCCS-vsn: usr.sbin/sendmail/src/usersmtp.c 6.11
SCCS-vsn: usr.sbin/sendmail/src/recipient.c 6.11
SCCS-vsn: usr.sbin/sendmail/src/main.c 6.19
SCCS-vsn: usr.sbin/sendmail/src/parseaddr.c 6.16
SCCS-vsn: usr.sbin/sendmail/src/conf.c 6.16

usr/src/usr.sbin/sendmail/src/conf.c
usr/src/usr.sbin/sendmail/src/main.c
usr/src/usr.sbin/sendmail/src/parseaddr.c
usr/src/usr.sbin/sendmail/src/recipient.c
usr/src/usr.sbin/sendmail/src/usersmtp.c

index c626655..592a41d 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)conf.c     6.15 (Berkeley) %G%";
+static char sccsid[] = "@(#)conf.c     6.16 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <sys/ioctl.h>
 #endif /* not lint */
 
 # include <sys/ioctl.h>
@@ -846,6 +846,9 @@ reapchild()
        while (wait((int *)&status) > 0)
                continue;
 # endif /* WNOHANG */
        while (wait((int *)&status) > 0)
                continue;
 # endif /* WNOHANG */
+# ifdef SYSTEM5
+       (void) signal(SIGCHLD, reapchild);
+# endif
 }
 \f/*
 **  UNSETENV -- remove a variable from the environment
 }
 \f/*
 **  UNSETENV -- remove a variable from the environment
index 75fd124..b166369 100644 (file)
@@ -13,7 +13,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     6.18 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     6.19 (Berkeley) %G%";
 #endif /* not lint */
 
 #define        _DEFINE
 #endif /* not lint */
 
 #define        _DEFINE
@@ -450,7 +450,7 @@ main(argc, argv, envp)
                                *q++ = '\0';
                        if (*optarg != '\0')
                                define('r', newstr(optarg), CurEnv);
                                *q++ = '\0';
                        if (*optarg != '\0')
                                define('r', newstr(optarg), CurEnv);
-                       if (*q != '\0')
+                       if (q != NULL && *q != '\0')
                                define('s', newstr(q), CurEnv);
                        break;
 
                                define('s', newstr(q), CurEnv);
                        break;
 
index b3f179a..66ed731 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)parseaddr.c        6.15 (Berkeley) %G%";
+static char sccsid[] = "@(#)parseaddr.c        6.16 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -459,7 +459,9 @@ prescan(addr, delim, pvpbuf)
                        if (bslashmode)
                        {
                                /* kludge \! for naive users */
                        if (bslashmode)
                        {
                                /* kludge \! for naive users */
-                               if (c != '!')
+                               if (cmntcnt > 0)
+                                       c = NOCHAR;
+                               else if (c != '!')
                                        *q++ = '\\';
                                bslashmode = FALSE;
                                if (cmntcnt > 0)
                                        *q++ = '\\';
                                bslashmode = FALSE;
                                if (cmntcnt > 0)
index c034b9a..ba74429 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)recipient.c        6.10 (Berkeley) %G%";
+static char sccsid[] = "@(#)recipient.c        6.11 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <sys/types.h>
 #endif /* not lint */
 
 # include <sys/types.h>
@@ -58,7 +58,6 @@ sendto(list, copyf, ctladdr, qflags)
        register char *p;
        register ADDRESS *al;   /* list of addresses to send to */
        bool firstone;          /* set on first address sent */
        register char *p;
        register ADDRESS *al;   /* list of addresses to send to */
        bool firstone;          /* set on first address sent */
-       bool selfref;           /* set if this list includes ctladdr */
        char delimiter;         /* the address delimiter */
        ADDRESS *sibl;          /* sibling pointer in tree */
        ADDRESS *prev;          /* previous sibling */
        char delimiter;         /* the address delimiter */
        ADDRESS *sibl;          /* sibling pointer in tree */
        ADDRESS *prev;          /* previous sibling */
@@ -79,7 +78,6 @@ sendto(list, copyf, ctladdr, qflags)
                delimiter = ',';
 
        firstone = TRUE;
                delimiter = ',';
 
        firstone = TRUE;
-       selfref = FALSE;
        al = NULL;
 
        for (p = list; *p != '\0'; )
        al = NULL;
 
        for (p = list; *p != '\0'; )
@@ -106,13 +104,13 @@ sendto(list, copyf, ctladdr, qflags)
                        a->q_flags |= QPRIMARY;
 
                if (ctladdr != NULL && sameaddr(ctladdr, a))
                        a->q_flags |= QPRIMARY;
 
                if (ctladdr != NULL && sameaddr(ctladdr, a))
-                       selfref = TRUE;
+                       ctladdr->q_flags |= QSELFREF;
                al = a;
                firstone = FALSE;
        }
 
        /* if this alias doesn't include itself, delete ctladdr */
                al = a;
                firstone = FALSE;
        }
 
        /* if this alias doesn't include itself, delete ctladdr */
-       if (!selfref && ctladdr != NULL)
+       if (ctladdr != NULL && !bitset(QSELFREF, ctladdr->q_flags))
        {
                if (tTd(25, 5))
                {
        {
                if (tTd(25, 5))
                {
@@ -702,6 +700,7 @@ include(fname, forwarding, ctladdr, sendq, e)
        {
                int ret = errno;
 
        {
                int ret = errno;
 
+               clrevent(ev);
                usrerr("Cannot open %s", fname);
                return ret;
        }
                usrerr("Cannot open %s", fname);
                return ret;
        }
@@ -711,7 +710,13 @@ include(fname, forwarding, ctladdr, sendq, e)
                struct stat st;
 
                if (fstat(fileno(fp), &st) < 0)
                struct stat st;
 
                if (fstat(fileno(fp), &st) < 0)
+               {
+                       int ret = errno;
+
+                       clrevent(ev);
                        syserr("Cannot fstat %s!", fname);
                        syserr("Cannot fstat %s!", fname);
+                       return ret;
+               }
                ctladdr->q_uid = st.st_uid;
                ctladdr->q_gid = st.st_gid;
                ctladdr->q_flags |= QGOODUID;
                ctladdr->q_uid = st.st_uid;
                ctladdr->q_gid = st.st_gid;
                ctladdr->q_flags |= QGOODUID;
index d6555f0..522fda5 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef SMTP
 
 #ifndef lint
 #ifdef SMTP
-static char sccsid[] = "@(#)usersmtp.c 6.10 (Berkeley) %G% (with SMTP)";
+static char sccsid[] = "@(#)usersmtp.c 6.11 (Berkeley) %G% (with SMTP)";
 #else
 #else
-static char sccsid[] = "@(#)usersmtp.c 6.10 (Berkeley) %G% (without SMTP)";
+static char sccsid[] = "@(#)usersmtp.c 6.11 (Berkeley) %G% (without SMTP)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -444,7 +444,7 @@ smtpnoop(mci)
 
        smtpmessage("NOOP", m, mci);
        r = reply(m, mci, e, ReadTimeout);
 
        smtpmessage("NOOP", m, mci);
        r = reply(m, mci, e, ReadTimeout);
-       if (REPLYTYPE(r) != 2)
+       if (r < 0 || REPLYTYPE(r) != 2)
                smtpquit(m, mci, e);
        return r;
 }
                smtpquit(m, mci, e);
        return r;
 }
@@ -556,6 +556,10 @@ reply(m, mci, e, timeout)
                if (r < 100)
                        continue;
 
                if (r < 100)
                        continue;
 
+               /* save temporary failure messages for posterity */
+               if (SmtpReplyBuffer[0] == '4' && SmtpError[0] == '\0')
+                       (void) strcpy(SmtpError, SmtpReplyBuffer);
+
                /* reply code 421 is "Service Shutting Down" */
                if (r == SMTPCLOSING && mci->mci_state != MCIS_SSD)
                {
                /* reply code 421 is "Service Shutting Down" */
                if (r == SMTPCLOSING && mci->mci_state != MCIS_SSD)
                {
@@ -564,10 +568,6 @@ reply(m, mci, e, timeout)
                        smtpquit(m, mci, e);
                }
 
                        smtpquit(m, mci, e);
                }
 
-               /* save temporary failure messages for posterity */
-               if (SmtpReplyBuffer[0] == '4' && SmtpError[0] == '\0')
-                       (void) strcpy(SmtpError, SmtpReplyBuffer);
-
                return (r);
        }
 }
                return (r);
        }
 }