fix a variety of small bugs noticed by bcx
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Thu, 5 Nov 1992 04:14:58 +0000 (20:14 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Thu, 5 Nov 1992 04:14:58 +0000 (20:14 -0800)
SCCS-vsn: usr.sbin/sendmail/src/headers.c 5.22
SCCS-vsn: usr.sbin/sendmail/src/parseaddr.c 5.22
SCCS-vsn: usr.sbin/sendmail/src/collect.c 5.13
SCCS-vsn: usr.sbin/sendmail/src/version.c 5.119
SCCS-vsn: usr.sbin/sendmail/src/daemon.c 5.50
SCCS-vsn: usr.sbin/sendmail/src/readcf.c 5.47
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 5.65

usr/src/usr.sbin/sendmail/src/collect.c
usr/src/usr.sbin/sendmail/src/daemon.c
usr/src/usr.sbin/sendmail/src/deliver.c
usr/src/usr.sbin/sendmail/src/headers.c
usr/src/usr.sbin/sendmail/src/parseaddr.c
usr/src/usr.sbin/sendmail/src/readcf.c
usr/src/usr.sbin/sendmail/src/version.c

index 0905b01..d5b19f5 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)collect.c  5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)collect.c  5.13 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <errno.h>
 #endif /* not lint */
 
 # include <errno.h>
@@ -134,7 +134,8 @@ maketemp(from)
 
                                /* we have room for more of this field */
                                fixcrlf(freebuf, TRUE);
 
                                /* we have room for more of this field */
                                fixcrlf(freebuf, TRUE);
-                               *p++ = '\n'; workbuflen++;
+                               *p++ = '\n';
+                               workbuflen++;
                                while(*q != '\0' && workbuflen < MAXFIELD-1)
                                {
                                        *p++ = *q++;
                                while(*q != '\0' && workbuflen < MAXFIELD-1)
                                {
                                        *p++ = *q++;
index 5aa9d38..ebef8b1 100644 (file)
@@ -12,9 +12,9 @@
 
 #ifndef lint
 #ifdef DAEMON
 
 #ifndef lint
 #ifdef DAEMON
-static char sccsid[] = "@(#)daemon.c   5.49 (Berkeley) %G% (with daemon mode)";
+static char sccsid[] = "@(#)daemon.c   5.50 (Berkeley) %G% (with daemon mode)";
 #else
 #else
-static char sccsid[] = "@(#)daemon.c   5.49 (Berkeley) %G% (without daemon mode)";
+static char sccsid[] = "@(#)daemon.c   5.50 (Berkeley) %G% (without daemon mode)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -442,7 +442,12 @@ maphostname(hbuf, hbsize, avp)
                {
                        /* found a match -- add the trailing dot */
                        if (ConfigLevel >= 2)
                {
                        /* found a match -- add the trailing dot */
                        if (ConfigLevel >= 2)
-                               (void) strcat(hbuf, ".");
+                       {
+                               int i = strlen(hbuf) - 1;
+
+                               if (hbuf[i] != '.')
+                                       (void) strcpy(&hbuf[++i], ".");
+                       }
                        return hbuf;
                }
                else
                        return hbuf;
                }
                else
index d0d87f2..a959dca 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)deliver.c  5.64 (Berkeley) %G%";
+static char sccsid[] = "@(#)deliver.c  5.65 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -860,6 +860,7 @@ openmailer(m, pvp, ctladdr, clever, e)
                else if (pid == 0)
                {
                        int i;
                else if (pid == 0)
                {
                        int i;
+                       int saveerrno;
                        extern int DtableSize;
 
                        /* child -- set up input & exec mailer */
                        extern int DtableSize;
 
                        /* child -- set up input & exec mailer */
@@ -922,10 +923,11 @@ openmailer(m, pvp, ctladdr, clever, e)
 
                        /* try to execute the mailer */
                        execve(m->m_mailer, pvp, UserEnviron);
 
                        /* try to execute the mailer */
                        execve(m->m_mailer, pvp, UserEnviron);
+                       saveerrno = errno;
                        syserr("Cannot exec %s", m->m_mailer);
                        if (m == LocalMailer)
                                _exit(EX_TEMPFAIL);
                        syserr("Cannot exec %s", m->m_mailer);
                        if (m == LocalMailer)
                                _exit(EX_TEMPFAIL);
-                       switch (errno)
+                       switch (saveerrno)
                        {
                          case EIO:
                          case EAGAIN:
                        {
                          case EIO:
                          case EAGAIN:
index 50d19be..88b29e3 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)headers.c  5.21 (Berkeley) %G%";
+static char sccsid[] = "@(#)headers.c  5.22 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <sys/param.h>
 #endif /* not lint */
 
 # include <sys/param.h>
@@ -54,7 +54,7 @@ chompheader(line, def, e)
        /* strip off options */
        clrbitmap(mopts);
        p = line;
        /* strip off options */
        clrbitmap(mopts);
        p = line;
-       if (*p == '?')
+       if (def && *p == '?')
        {
                /* have some */
                register char *q = index(p + 1, *p);
        {
                /* have some */
                register char *q = index(p + 1, *p);
index 583c3e1..1a611c9 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)parseaddr.c        5.13.1.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)parseaddr.c        5.22 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -652,6 +652,11 @@ _rewrite(pvp, ruleset)
                printf("rewrite: ruleset %2d   input:", ruleset);
                printcav(pvp);
        }
                printf("rewrite: ruleset %2d   input:", ruleset);
                printcav(pvp);
        }
+       if (ruleset < 0 || ruleset >= MAXRWSETS)
+       {
+               syserr("rewrite: illegal ruleset number %d", ruleset);
+               return;
+       }
        if (pvp == NULL)
                return;
 
        if (pvp == NULL)
                return;
 
@@ -734,6 +739,8 @@ _rewrite(pvp, ruleset)
                        if (++loopcount > 100)
                        {
                                syserr("Infinite loop in ruleset %d", ruleset);
                        if (++loopcount > 100)
                        {
                                syserr("Infinite loop in ruleset %d", ruleset);
+                               printf("workspace: ");
+                               printav(pvp);
                                break;
                        }
                        rp = *rvp;
                                break;
                        }
                        rp = *rvp;
@@ -1078,7 +1085,7 @@ backup:
                        {
                                /* substitute from LHS */
                                m = &mlist[rp[1] - '1'];
                        {
                                /* substitute from LHS */
                                m = &mlist[rp[1] - '1'];
-                               if (m >= mlp)
+                               if (m < mlist || m >= mlp)
                                {
                                  toolong:
                                        syserr("rewrite: ruleset %d: replacement #%c out of bounds",
                                {
                                  toolong:
                                        syserr("rewrite: ruleset %d: replacement #%c out of bounds",
index bc2b0e1..2142ba8 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)readcf.c   5.46 (Berkeley) %G%";
+static char sccsid[] = "@(#)readcf.c   5.47 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -201,6 +201,8 @@ readcf(cfname)
                        rwp->r_lhs = prescan(exbuf, '\t', pvpbuf);
                        if (rwp->r_lhs != NULL)
                                rwp->r_lhs = copyplist(rwp->r_lhs, TRUE);
                        rwp->r_lhs = prescan(exbuf, '\t', pvpbuf);
                        if (rwp->r_lhs != NULL)
                                rwp->r_lhs = copyplist(rwp->r_lhs, TRUE);
+                       else
+                               syserr("R line: null LHS");
 
                        /* expand and save the RHS */
                        while (*++p == '\t')
 
                        /* expand and save the RHS */
                        while (*++p == '\t')
@@ -213,6 +215,8 @@ readcf(cfname)
                        rwp->r_rhs = prescan(exbuf, '\t', pvpbuf);
                        if (rwp->r_rhs != NULL)
                                rwp->r_rhs = copyplist(rwp->r_rhs, TRUE);
                        rwp->r_rhs = prescan(exbuf, '\t', pvpbuf);
                        if (rwp->r_rhs != NULL)
                                rwp->r_rhs = copyplist(rwp->r_rhs, TRUE);
+                       else
+                               syserr("R line: null RHS");
                        break;
 
                  case 'S':             /* select rewriting set */
                        break;
 
                  case 'S':             /* select rewriting set */
index 25ffb24..4808929 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)version.c  5.118 (Berkeley) %G%";
+static char sccsid[] = "@(#)version.c  5.119 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-char   Version[] = "5.118";
+char   Version[] = "5.119";