diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-09-17 17:31:42 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-09-17 17:31:42 +0000 |
commit | e883408a0913641ec2d452de3978a47db5f4c85e (patch) | |
tree | 32d45bdda26765a93ea86ef564a3ec12a3fa0416 /gnu/usr.sbin/sendmail/libsm | |
parent | dcd8a09464d293189795148dba784b422795dd9f (diff) |
Update to sendmail-8.12.10. This includes a fix for a buffer overflow
in address parsing. That fix (but not all of sendmail-8.12.10) has
been applied to OpenBSD 3.4 and the 3.2 and 3.2 -stable branches.
Diffstat (limited to 'gnu/usr.sbin/sendmail/libsm')
-rw-r--r-- | gnu/usr.sbin/sendmail/libsm/clock.c | 116 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libsm/errstring.c | 10 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libsm/flags.c | 8 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libsm/ldap.c | 4 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libsm/shm.c | 9 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libsm/smstdio.c | 19 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libsm/stdio.c | 16 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libsm/vasprintf.c | 2 |
8 files changed, 165 insertions, 19 deletions
diff --git a/gnu/usr.sbin/sendmail/libsm/clock.c b/gnu/usr.sbin/sendmail/libsm/clock.c index 4bfd22f176f..ca5031b19a2 100644 --- a/gnu/usr.sbin/sendmail/libsm/clock.c +++ b/gnu/usr.sbin/sendmail/libsm/clock.c @@ -12,7 +12,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Sendmail: clock.c,v 1.35.2.3 2003/03/03 19:57:40 ca Exp $") +SM_RCSID("@(#)$Sendmail: clock.c,v 1.35.2.10 2003/06/26 16:36:49 ca Exp $") #include <unistd.h> #include <time.h> #include <errno.h> @@ -24,13 +24,17 @@ SM_RCSID("@(#)$Sendmail: clock.c,v 1.35.2.3 2003/03/03 19:57:40 ca Exp $") #include <sm/bitops.h> #include <sm/clock.h> #include "local.h" +#if _FFR_SLEEP_USE_SELECT > 0 +# include <sys/types.h> +#endif /* _FFR_SLEEP_USE_SELECT > 0 */ +#if defined(_FFR_MAX_SLEEP_TIME) && _FFR_MAX_SLEEP_TIME > 2 +# include <syslog.h> +#endif /* defined(_FFR_MAX_SLEEP_TIME) && _FFR_MAX_SLEEP_TIME > 2 */ #ifndef sigmask # define sigmask(s) (1 << ((s) - 1)) #endif /* ! sigmask */ -static void sm_endsleep __P((void)); - /* ** SM_SETEVENTM -- set an event to happen at a specific time in milliseconds. @@ -136,6 +140,8 @@ sm_sigsafe_seteventm(intvl, func, arg) */ LEAVE_CRITICAL(); + if (wasblocked == 0) + (void) sm_releasesignal(SIGALRM); return NULL; } else @@ -490,7 +496,10 @@ sm_tick(sig) */ +# if !HAVE_NANOSLEEP +static void sm_endsleep __P((void)); static bool volatile SmSleepDone; +# endif /* !HAVE_NANOSLEEP */ #ifndef SLEEP_T # define SLEEP_T unsigned int @@ -500,20 +509,118 @@ SLEEP_T sleep(intvl) unsigned int intvl; { +#if HAVE_NANOSLEEP + struct timespec rqtp; + + if (intvl == 0) + return (SLEEP_T) 0; + rqtp.tv_sec = intvl; + rqtp.tv_nsec = 0; + nanosleep(&rqtp, NULL); + return (SLEEP_T) 0; +#else /* HAVE_NANOSLEEP */ int was_held; + SM_EVENT *ev; +#if _FFR_SLEEP_USE_SELECT > 0 + int r; +#endif /* _FFR_SLEEP_USE_SELECT > 0 */ +#if SM_CONF_SETITIMER + struct timeval now, begin, diff; +# if _FFR_SLEEP_USE_SELECT > 0 + struct timeval sm_io_to, slpv; +# endif /* _FFR_SLEEP_USE_SELECT > 0 */ +#else /* SM_CONF_SETITIMER */ + time_t begin, now; +#endif /* SM_CONF_SETITIMER */ if (intvl == 0) return (SLEEP_T) 0; +#if defined(_FFR_MAX_SLEEP_TIME) && _FFR_MAX_SLEEP_TIME > 2 + if (intvl > _FFR_MAX_SLEEP_TIME) + { + syslog(LOG_ERR, "sleep: interval=%u exceeds max value %d", + intvl, _FFR_MAX_SLEEP_TIME); +# if 0 + SM_ASSERT(intvl < (unsigned int) INT_MAX); +# endif /* 0 */ + intvl = _FFR_MAX_SLEEP_TIME; + } +#endif /* defined(_FFR_MAX_SLEEP_TIME) && _FFR_MAX_SLEEP_TIME > 2 */ SmSleepDone = false; - (void) sm_setevent((time_t) intvl, sm_endsleep, 0); + +#if SM_CONF_SETITIMER +# if _FFR_SLEEP_USE_SELECT > 0 + slpv.tv_sec = intvl; + slpv.tv_usec = 0; +# endif /* _FFR_SLEEP_USE_SELECT > 0 */ + (void) gettimeofday(&now, NULL); + begin = now; +#else /* SM_CONF_SETITIMER */ + now = begin = time(NULL); +#endif /* SM_CONF_SETITIMER */ + + ev = sm_setevent((time_t) intvl, sm_endsleep, 0); + if (ev == NULL) + { + /* COMPLAIN */ +#if 0 + syslog(LOG_ERR, "sleep: sm_setevent(%u) failed", intvl); +#endif /* 0 */ + SmSleepDone = true; + } was_held = sm_releasesignal(SIGALRM); + while (!SmSleepDone) + { +#if SM_CONF_SETITIMER + (void) gettimeofday(&now, NULL); + timersub(&now, &begin, &diff); + if (diff.tv_sec < 0 || + (diff.tv_sec == 0 && diff.tv_usec == 0)) + break; +# if _FFR_SLEEP_USE_SELECT > 0 + timersub(&slpv, &diff, &sm_io_to); +# endif /* _FFR_SLEEP_USE_SELECT > 0 */ +#else /* SM_CONF_SETITIMER */ + now = time(NULL); + + /* + ** Check whether time expired before signal is released. + ** Due to the granularity of time() add 1 to be on the + ** safe side. + */ + + if (!(begin + (time_t) intvl + 1 > now)) + break; +# if _FFR_SLEEP_USE_SELECT > 0 + sm_io_to.tv_sec = intvl - (now - begin); + if (sm_io_to.tv_sec <= 0) + sm_io_to.tv_sec = 1; + sm_io_to.utv_sec = 0; +# endif /* _FFR_SLEEP_USE_SELECT > 0 */ +#endif /* SM_CONF_SETITIMER */ +#if _FFR_SLEEP_USE_SELECT > 0 + if (intvl <= _FFR_SLEEP_USE_SELECT) + { + r = select(0, NULL, NULL, NULL, &sm_io_to); + if (r == 0) + break; + } + else +#endif /* _FFR_SLEEP_USE_SELECT > 0 */ (void) pause(); + } + + /* if out of the loop without the event being triggered remove it */ + if (!SmSleepDone) + sm_clrevent(ev); if (was_held > 0) (void) sm_blocksignal(SIGALRM); return (SLEEP_T) 0; +#endif /* HAVE_NANOSLEEP */ } +#if !HAVE_NANOSLEEP static void sm_endsleep() { @@ -525,4 +632,5 @@ sm_endsleep() SmSleepDone = true; } +#endif /* !HAVE_NANOSLEEP */ diff --git a/gnu/usr.sbin/sendmail/libsm/errstring.c b/gnu/usr.sbin/sendmail/libsm/errstring.c index 484614fad25..f9e1bb5cbf9 100644 --- a/gnu/usr.sbin/sendmail/libsm/errstring.c +++ b/gnu/usr.sbin/sendmail/libsm/errstring.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001 Sendmail, Inc. and its suppliers. + * Copyright (c) 2001, 2003 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 @@ -11,7 +11,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Sendmail: errstring.c,v 1.12 2001/10/03 16:09:32 ca Exp $") +SM_RCSID("@(#)$Sendmail: errstring.c,v 1.12.2.4 2003/06/24 17:16:09 ca Exp $") #include <errno.h> #include <stdio.h> /* sys_errlist, on some platforms */ @@ -42,6 +42,8 @@ SM_RCSID("@(#)$Sendmail: errstring.c,v 1.12 2001/10/03 16:09:32 ca Exp $") ** ** Returns: ** A string description of errnum. +** +** Note: this may point to a local (static) buffer. */ const char * @@ -50,6 +52,7 @@ sm_errstring(errnum) { char *ret; + switch (errnum) { case EPERM: @@ -183,6 +186,9 @@ sm_errstring(errnum) case SMDBE_OLD_VERSION: return "Berkeley DB file is an old version, recreate it"; + + case SMDBE_VERSION_MISMATCH: + return "Berkeley DB version mismatch between include file and library"; } /* diff --git a/gnu/usr.sbin/sendmail/libsm/flags.c b/gnu/usr.sbin/sendmail/libsm/flags.c index 7cacf95e823..bbd548b7c7b 100644 --- a/gnu/usr.sbin/sendmail/libsm/flags.c +++ b/gnu/usr.sbin/sendmail/libsm/flags.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers. + * Copyright (c) 2000-2001, 2003 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -13,7 +13,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Sendmail: flags.c,v 1.20 2001/09/11 04:04:48 gshapiro Exp $") +SM_RCSID("@(#)$Sendmail: flags.c,v 1.20.2.1 2003/09/03 18:51:56 ca Exp $") #include <sys/types.h> #include <sys/file.h> #include <errno.h> @@ -35,7 +35,7 @@ sm_flags(flags) { register int ret; - switch(flags) + switch(SM_IO_MODE(flags)) { case SM_IO_RDONLY: /* open for reading */ ret = SMRD; @@ -57,5 +57,7 @@ sm_flags(flags) ret = 0; break; } + if (SM_IS_BINARY(flags)) + ret |= SM_IO_BINARY; return ret; } diff --git a/gnu/usr.sbin/sendmail/libsm/ldap.c b/gnu/usr.sbin/sendmail/libsm/ldap.c index 68cbe7ff0c1..da75b3d2581 100644 --- a/gnu/usr.sbin/sendmail/libsm/ldap.c +++ b/gnu/usr.sbin/sendmail/libsm/ldap.c @@ -8,7 +8,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Sendmail: ldap.c,v 1.44.2.2 2002/08/09 22:23:12 gshapiro Exp $") +SM_RCSID("@(#)$Sendmail: ldap.c,v 1.44.2.3 2003/07/07 20:16:16 gshapiro Exp $") #if LDAPMAP # include <sys/types.h> @@ -582,7 +582,7 @@ sm_ldap_results(lmap, msgid, flags, delim, rpool, result, save_errno += E_LDAPBASE; SM_LDAP_ERROR_CLEANUP(); errno = save_errno; - return EX_OSERR; + return EX_TEMPFAIL; } rl = sm_ldap_add_recurse(&recurse, dn, diff --git a/gnu/usr.sbin/sendmail/libsm/shm.c b/gnu/usr.sbin/sendmail/libsm/shm.c index f19fa9a8cf0..8c5bbde4e50 100644 --- a/gnu/usr.sbin/sendmail/libsm/shm.c +++ b/gnu/usr.sbin/sendmail/libsm/shm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers. + * Copyright (c) 2000-2001, 2003 Sendmail, Inc. and its suppliers. * All rights reserved. * * By using this file, you agree to the terms and conditions set @@ -8,7 +8,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Sendmail: shm.c,v 1.10 2001/12/14 00:22:58 ca Exp $") +SM_RCSID("@(#)$Sendmail: shm.c,v 1.10.2.6 2003/06/13 21:17:48 ca Exp $") #if SM_CONF_SHM # include <stdlib.h> @@ -16,6 +16,7 @@ SM_RCSID("@(#)$Sendmail: shm.c,v 1.10 2001/12/14 00:22:58 ca Exp $") # include <errno.h> # include <sm/shm.h> + /* ** SM_SHMSTART -- initialize shared memory segment. ** @@ -69,6 +70,7 @@ sm_shmstart(key, size, shmflg, shmid, owner) return (void *) 0; } + /* ** SM_SHMSTOP -- stop using shared memory segment. ** @@ -85,6 +87,7 @@ sm_shmstart(key, size, shmflg, shmid, owner) ** detaches (and maybe removes) shared memory segment. */ + int sm_shmstop(shm, shmid, owner) void *shm; @@ -99,4 +102,6 @@ sm_shmstop(shm, shmid, owner) return r; return 0; } + + #endif /* SM_CONF_SHM */ diff --git a/gnu/usr.sbin/sendmail/libsm/smstdio.c b/gnu/usr.sbin/sendmail/libsm/smstdio.c index 28817a8bdc0..15da189fe6e 100644 --- a/gnu/usr.sbin/sendmail/libsm/smstdio.c +++ b/gnu/usr.sbin/sendmail/libsm/smstdio.c @@ -8,7 +8,7 @@ */ #include <sm/gen.h> -SM_IDSTR(id, "@(#)$Sendmail: smstdio.c,v 1.32 2002/02/23 20:18:36 gshapiro Exp $") +SM_IDSTR(id, "@(#)$Sendmail: smstdio.c,v 1.32.2.2 2003/09/05 20:35:28 ca Exp $") #include <unistd.h> #include <stdio.h> #include <fcntl.h> @@ -68,6 +68,23 @@ sm_stdioopen(fp, info, flags, rpool) case SM_IO_APPENDRW: stdiomode = "a+"; break; +#if SM_IO_BINARY != 0 + case SM_IO_RDONLY_B: + stdiomode = "rb"; + break; + case SM_IO_WRONLY_B: + stdiomode = "wb"; + break; + case SM_IO_APPEND_B: + stdiomode = "ab"; + break; + case SM_IO_APPENDRW_B: + stdiomode = "a+b"; + break; + case SM_IO_RDWR_B: + stdiomode = "r+b"; + break; +#endif /* SM_IO_BINARY != 0 */ case SM_IO_RDWR: default: stdiomode = "r+"; diff --git a/gnu/usr.sbin/sendmail/libsm/stdio.c b/gnu/usr.sbin/sendmail/libsm/stdio.c index c81440ba801..8a9cf6641d2 100644 --- a/gnu/usr.sbin/sendmail/libsm/stdio.c +++ b/gnu/usr.sbin/sendmail/libsm/stdio.c @@ -13,7 +13,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Sendmail: stdio.c,v 1.56.2.10 2003/01/10 23:07:17 ca Exp $") +SM_RCSID("@(#)$Sendmail: stdio.c,v 1.56.2.13 2003/09/04 01:18:08 ca Exp $") #include <unistd.h> #include <errno.h> #include <fcntl.h> @@ -63,7 +63,7 @@ sm_stdopen(fp, info, flags, rpool) char *path = (char *) info; int oflags; - switch (flags) + switch (SM_IO_MODE(flags)) { case SM_IO_RDWR: oflags = O_RDWR; @@ -87,6 +87,10 @@ sm_stdopen(fp, info, flags, rpool) errno = EINVAL; return -1; } +#ifdef O_BINARY + if (SM_IS_BINARY(flags)) + oflags |= O_BINARY; +#endif /* O_BINARY */ fp->f_file = open(path, oflags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); if (fp->f_file < 0) @@ -221,7 +225,7 @@ sm_stdsetmode(fp, mode) { int flags = 0; - switch (*mode) + switch (SM_IO_MODE(*mode)) { case SM_IO_RDWR: flags |= SMRW; @@ -402,7 +406,7 @@ sm_stdfdopen(fp, info, flags, rpool) { int oflags, tmp, fdflags, fd = *((int *) info); - switch (flags) + switch (SM_IO_MODE(flags)) { case SM_IO_RDWR: oflags = O_RDWR | O_CREAT; @@ -423,6 +427,10 @@ sm_stdfdopen(fp, info, flags, rpool) errno = EINVAL; return -1; } +#ifdef O_BINARY + if (SM_IS_BINARY(flags)) + oflags |= O_BINARY; +#endif /* O_BINARY */ /* Make sure the mode the user wants is a subset of the actual mode. */ if ((fdflags = fcntl(fd, F_GETFL, 0)) < 0) diff --git a/gnu/usr.sbin/sendmail/libsm/vasprintf.c b/gnu/usr.sbin/sendmail/libsm/vasprintf.c index 8120375cf84..f8e22b76ace 100644 --- a/gnu/usr.sbin/sendmail/libsm/vasprintf.c +++ b/gnu/usr.sbin/sendmail/libsm/vasprintf.c @@ -24,7 +24,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Sendmail: vasprintf.c,v 1.26 2001/09/11 04:04:49 gshapiro Exp $") +SM_RCSID("@(#)$Sendmail: vasprintf.c,v 1.26.2.1 2003/06/03 02:14:09 ca Exp $") #include <stdlib.h> #include <errno.h> #include <sm/io.h> |