Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-2]: src/gnu/dist/sendmail Apply patch (requested by christos in t...



details:   https://anonhg.NetBSD.org/src/rev/5e1a00cac91d
branches:  netbsd-2
changeset: 564438:5e1a00cac91d
user:      riz <riz%NetBSD.org@localhost>
date:      Fri Mar 24 19:12:42 2006 +0000

description:
Apply patch (requested by christos in ticket #10383):
        gnu/dist/sendmail/libsm/fflush.c: patch
        gnu/dist/sendmail/libsm/local.h: patch
        gnu/dist/sendmail/libsm/refill.c: patch
        gnu/dist/sendmail/sendmail/collect.c: patch
        gnu/dist/sendmail/sendmail/conf.c: patch
        gnu/dist/sendmail/sendmail/deliver.c: patch
        gnu/dist/sendmail/sendmail/headers.c: patch
        gnu/dist/sendmail/sendmail/mime.c: patch
        gnu/dist/sendmail/sendmail/parseaddr.c: patch
        gnu/dist/sendmail/sendmail/savemail.c: patch
        gnu/dist/sendmail/sendmail/sendmail.h: patch
        gnu/dist/sendmail/sendmail/sfsasl.c: patch
        gnu/dist/sendmail/sendmail/sfsasl.h: patch
        gnu/dist/sendmail/sendmail/srvrsmtp.c: patch
        gnu/dist/sendmail/sendmail/tls.c: patch
        gnu/dist/sendmail/sendmail/usersmtp.c: patch
        gnu/dist/sendmail/sendmail/util.c: patch
        gnu/dist/sendmail/sendmail/version.c: patch
Apply patch 8.12.11.p0 from sendmail.org, with local compile fixes.

diffstat:

 gnu/dist/sendmail/libsm/fflush.c       |    5 +-
 gnu/dist/sendmail/libsm/local.h        |   20 +-
 gnu/dist/sendmail/libsm/refill.c       |   13 +-
 gnu/dist/sendmail/sendmail/collect.c   |  165 +++++++++-----------
 gnu/dist/sendmail/sendmail/conf.c      |   23 +-
 gnu/dist/sendmail/sendmail/deliver.c   |  250 +++++++++++--------------------
 gnu/dist/sendmail/sendmail/headers.c   |   69 +++++---
 gnu/dist/sendmail/sendmail/mime.c      |  126 ++++++++++-----
 gnu/dist/sendmail/sendmail/parseaddr.c |   16 +-
 gnu/dist/sendmail/sendmail/savemail.c  |  259 ++++++++++++++++++++------------
 gnu/dist/sendmail/sendmail/sendmail.h  |   23 +-
 gnu/dist/sendmail/sendmail/sfsasl.c    |  226 +++++++++++++++++++++++-----
 gnu/dist/sendmail/sendmail/sfsasl.h    |    4 +-
 gnu/dist/sendmail/sendmail/srvrsmtp.c  |   94 +----------
 gnu/dist/sendmail/sendmail/tls.c       |    6 +-
 gnu/dist/sendmail/sendmail/usersmtp.c  |  105 +++---------
 gnu/dist/sendmail/sendmail/util.c      |   69 ++------
 gnu/dist/sendmail/sendmail/version.c   |    6 +-
 18 files changed, 758 insertions(+), 721 deletions(-)

diffs (truncated from 3078 to 300 lines):

diff -r ded5d54b691c -r 5e1a00cac91d gnu/dist/sendmail/libsm/fflush.c
--- a/gnu/dist/sendmail/libsm/fflush.c  Mon Mar 20 17:55:47 2006 +0000
+++ b/gnu/dist/sendmail/libsm/fflush.c  Fri Mar 24 19:12:42 2006 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: fflush.c,v 1.1.1.2 2003/06/01 14:01:34 atatat Exp $ */
+/* $NetBSD: fflush.c,v 1.1.1.2.4.1 2006/03/24 19:12:42 riz Exp $ */
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: fflush.c,v 1.1.1.2 2003/06/01 14:01:34 atatat Exp $");
+__RCSID("$NetBSD: fflush.c,v 1.1.1.2.4.1 2006/03/24 19:12:42 riz Exp $");
 #endif
 
 /*
@@ -151,6 +151,7 @@
                                return SM_IO_EOF;
                        }
                        SM_IO_WR_TIMEOUT(fp, fd, *timeout);
+                       t = 0;
                }
        }
        return 0;
diff -r ded5d54b691c -r 5e1a00cac91d gnu/dist/sendmail/libsm/local.h
--- a/gnu/dist/sendmail/libsm/local.h   Mon Mar 20 17:55:47 2006 +0000
+++ b/gnu/dist/sendmail/libsm/local.h   Fri Mar 24 19:12:42 2006 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: local.h,v 1.1.1.3 2004/03/25 19:02:09 atatat Exp $ */
+/* $NetBSD: local.h,v 1.1.1.3.4.1 2006/03/24 19:12:42 riz Exp $ */
 /*
  * Copyright (c) 2000-2002, 2004 Sendmail, Inc. and its suppliers.
  *      All rights reserved.
@@ -193,7 +193,7 @@
        else \
        { \
                (time)->tv_sec = (val) / 1000; \
-               (time)->tv_usec = ((val) - ((time)->tv_sec * 1000)) * 10; \
+               (time)->tv_usec = ((val) - ((time)->tv_sec * 1000)) * 1000; \
        } \
        if ((val) == SM_TIME_FOREVER) \
        { \
@@ -277,7 +277,7 @@
        else \
        { \
                sm_io_to.tv_sec = (to) / 1000; \
-               sm_io_to.tv_usec = ((to) - (sm_io_to.tv_sec * 1000)) * 10; \
+               sm_io_to.tv_usec = ((to) - (sm_io_to.tv_sec * 1000)) * 1000; \
        } \
        if (FD_SETSIZE > 0 && (fd) >= FD_SETSIZE) \
        { \
@@ -290,8 +290,11 @@
        FD_SET((fd), &sm_io_x_mask); \
        if (gettimeofday(&sm_io_to_before, NULL) < 0) \
                return SM_IO_EOF; \
-       sm_io_to_sel = select((fd) + 1, NULL, &sm_io_to_mask, &sm_io_x_mask, \
-                             &sm_io_to); \
+       do \
+       {       \
+               sm_io_to_sel = select((fd) + 1, NULL, &sm_io_to_mask, \
+                                       &sm_io_x_mask, &sm_io_to); \
+       } while (sm_io_to_sel < 0 && errno == EINTR); \
        if (sm_io_to_sel < 0) \
        { \
                /* something went wrong, errno set */ \
@@ -306,10 +309,9 @@
        /* else loop again */ \
        if (gettimeofday(&sm_io_to_after, NULL) < 0) \
                return SM_IO_EOF; \
-       timersub(&sm_io_to_before, &sm_io_to_after, &sm_io_to_diff); \
-       timersub(&sm_io_to, &sm_io_to_diff, &sm_io_to); \
-       (to) -= (sm_io_to.tv_sec * 1000); \
-       (to) -= (sm_io_to.tv_usec / 10); \
+       timersub(&sm_io_to_after, &sm_io_to_before, &sm_io_to_diff); \
+       (to) -= (sm_io_to_diff.tv_sec * 1000); \
+       (to) -= (sm_io_to_diff.tv_usec / 1000); \
        if ((to) < 0) \
                (to) = 0; \
 }
diff -r ded5d54b691c -r 5e1a00cac91d gnu/dist/sendmail/libsm/refill.c
--- a/gnu/dist/sendmail/libsm/refill.c  Mon Mar 20 17:55:47 2006 +0000
+++ b/gnu/dist/sendmail/libsm/refill.c  Fri Mar 24 19:12:42 2006 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: refill.c,v 1.1.1.2 2003/06/01 14:01:37 atatat Exp $ */
+/* $NetBSD: refill.c,v 1.1.1.2.4.1 2006/03/24 19:12:42 riz Exp $ */
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: refill.c,v 1.1.1.2 2003/06/01 14:01:37 atatat Exp $");
+__RCSID("$NetBSD: refill.c,v 1.1.1.2.4.1 2006/03/24 19:12:42 riz Exp $");
 #endif
 
 /*
@@ -82,8 +82,11 @@
        FD_SET((fd), &sm_io_x_mask);                                    \
        if (gettimeofday(&sm_io_to_before, NULL) < 0)                   \
                return SM_IO_EOF;                                       \
-       (sel_ret) = select((fd) + 1, &sm_io_to_mask, NULL,              \
-                          &sm_io_x_mask, (to));                        \
+       do                                                              \
+       {                                                               \
+               (sel_ret) = select((fd) + 1, &sm_io_to_mask, NULL,      \
+                               &sm_io_x_mask, (to));                   \
+       } while ((sel_ret) < 0 && errno == EINTR);                      \
        if ((sel_ret) < 0)                                              \
        {                                                               \
                /* something went wrong, errno set */                   \
@@ -100,7 +103,7 @@
        /* calulate wall-clock time used */                             \
        if (gettimeofday(&sm_io_to_after, NULL) < 0)                    \
                return SM_IO_EOF;                                       \
-       timersub(&sm_io_to_before, &sm_io_to_after, &sm_io_to_diff);    \
+       timersub(&sm_io_to_after, &sm_io_to_before, &sm_io_to_diff);    \
        timersub((to), &sm_io_to_diff, (to));                           \
 }
 
diff -r ded5d54b691c -r 5e1a00cac91d gnu/dist/sendmail/sendmail/collect.c
--- a/gnu/dist/sendmail/sendmail/collect.c      Mon Mar 20 17:55:47 2006 +0000
+++ b/gnu/dist/sendmail/sendmail/collect.c      Fri Mar 24 19:12:42 2006 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: collect.c,v 1.11 2004/03/25 19:14:31 atatat Exp $ */
+/* $NetBSD: collect.c,v 1.11.4.1 2006/03/24 19:12:42 riz Exp $ */
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: collect.c,v 1.11 2004/03/25 19:14:31 atatat Exp $");
+__RCSID("$NetBSD: collect.c,v 1.11.4.1 2006/03/24 19:12:42 riz Exp $");
 #endif
 
 /*
@@ -21,7 +21,6 @@
 
 SM_RCSID("@(#)Id: collect.c,v 8.242.2.8 2003/07/08 01:16:35 ca Exp")
 
-static void    collecttimeout __P((time_t));
 static void    dferror __P((SM_FILE_T *volatile, char *, ENVELOPE *));
 static void    eatfrom __P((char *volatile, ENVELOPE *));
 static void    collect_doheader __P((ENVELOPE *));
@@ -270,10 +269,6 @@
 **             If data file cannot be created, the process is terminated.
 */
 
-static jmp_buf CtxCollectTimeout;
-static bool    volatile CollectProgress;
-static SM_EVENT        *volatile CollectTimeout = NULL;
-
 /* values for input state machine */
 #define IS_NORM                0       /* middle of line */
 #define IS_BOL         1       /* beginning of line */
@@ -296,26 +291,30 @@
        bool rsetsize;
 {
        register SM_FILE_T *volatile df;
-       volatile bool ignrdot;
-       volatile time_t dbto;
+       bool ignrdot;
+       int dbto;
        register char *volatile bp;
-       volatile int c;
-       volatile bool inputerr;
+       int c;
+       bool inputerr;
        bool headeronly;
-       char *volatile buf;
-       volatile int buflen;
-       volatile int istate;
-       volatile int mstate;
-       volatile int hdrslen;
-       volatile int numhdrs;
-       volatile int afd;
-       unsigned char *volatile pbp;
+       char *buf;
+       int buflen;
+       int istate;
+       int mstate;
+       int hdrslen;
+       int numhdrs;
+       int afd;
+       unsigned char *pbp;
        unsigned char peekbuf[8];
        char bufbuf[MAXLINE];
 
        df = NULL;
        ignrdot = smtpmode ? false : IgnrDot;
-       dbto = smtpmode ? TimeOuts.to_datablock : 0;
+
+       /* timeout for I/O functions is in milliseconds */
+       dbto = smtpmode ? ((int) TimeOuts.to_datablock * 1000)
+                       : SM_TIME_FOREVER;
+       sm_io_setinfo(fp, SM_IO_WHAT_TIMEOUT, &dbto);
        c = SM_IO_EOF;
        inputerr = false;
        headeronly = hdrp != NULL;
@@ -327,7 +326,6 @@
        pbp = peekbuf;
        istate = IS_BOL;
        mstate = SaveFrom ? MS_HEADER : MS_UFROM;
-       CollectProgress = false;
 
        /*
        **  Tell ARPANET to go ahead.
@@ -348,32 +346,6 @@
        **      the larger picture (e.g., header versus body).
        */
 
-       if (dbto != 0)
-       {
-               /* handle possible input timeout */
-               if (setjmp(CtxCollectTimeout) != 0)
-               {
-                       if (LogLevel > 2)
-                               sm_syslog(LOG_NOTICE, e->e_id,
-                                         "timeout waiting for input from %s during message collect",
-                                         CURHOSTNAME);
-                       errno = 0;
-                       if (smtpmode)
-                       {
-                               /*
-                               **  Override e_message in usrerr() as this
-                               **  is the reason for failure that should
-                               **  be logged for undelivered recipients.
-                               */
-
-                               e->e_message = NULL;
-                       }
-                       usrerr("451 4.4.1 timeout waiting for input during message collect");
-                       goto readerr;
-               }
-               CollectTimeout = sm_setevent(dbto, collecttimeout, dbto);
-       }
-
        if (rsetsize)
                e->e_msgsize = 0;
        for (;;)
@@ -397,9 +369,26 @@
                                                sm_io_clearerr(fp);
                                                continue;
                                        }
+
+                                       /* timeout? */
+                                       if (c == SM_IO_EOF && errno == EAGAIN
+                                           && smtpmode)
+                                       {
+                                               /*
+                                               **  Override e_message in
+                                               **  usrerr() as this is the
+                                               **  reason for failure that
+                                               **  should be logged for
+                                               **  undelivered recipients.
+                                               */
+
+                                               e->e_message = NULL;
+                                               errno = 0;
+                                               inputerr = true;
+                                               goto readabort;
+                                       }
                                        break;
                                }
-                               CollectProgress = true;
                                if (TrafficLogFile != NULL && !headeronly)
                                {
                                        if (istate == IS_BOL)
@@ -546,6 +535,18 @@
                                        buflen *= 2;
                                else
                                        buflen += MEMCHUNKSIZE;
+                               if (buflen <= 0)
+                               {
+                                       sm_syslog(LOG_NOTICE, e->e_id,
+                                                 "header overflow from %s during message collect",
+                                                 CURHOSTNAME);
+                                       errno = 0;
+                                       e->e_flags |= EF_CLRQUEUE;
+                                       e->e_status = "5.6.0";
+                                       usrerrenh(e->e_status,
+                                                 "552 Headers too large");
+                                       goto discard;
+                               }
                                buf = xalloc(buflen);
                                memmove(buf, obuf, bp - obuf);
                                bp = &buf[bp - obuf];
@@ -589,6 +590,7 @@
                                        usrerrenh(e->e_status,
                                                  "552 Headers too large (%d max)",
                                                  MaxHeadersLength);
+  discard:
                                        mstate = MS_DISCARD;
                                }
                        }
@@ -628,6 +630,24 @@
                                sm_io_clearerr(fp);
                                errno = 0;
                                c = sm_io_getc(fp, SM_TIME_DEFAULT);
+
+                               /* timeout? */
+                               if (c == SM_IO_EOF && errno == EAGAIN
+                                   && smtpmode)
+                               {
+                                       /*
+                                       **  Override e_message in
+                                       **  usrerr() as this is the
+                                       **  reason for failure that
+                                       **  should be logged for
+                                       **  undelivered recipients.
+                                       */



Home | Main Index | Thread Index | Old Index