diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2001-08-01 01:33:27 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2001-08-01 01:33:27 +0000 |
commit | e147a0c4ede93cc9e8a78357d38ea4c6183f45ae (patch) | |
tree | 18a1edd91ee0b43a66b413b2e9efffbc1a9575f8 /contrib/sendmail/libsmutil | |
parent | cceec8d18104db04cf807557e3517e2bc2437b10 (diff) | |
parent | 1164bba81c60839834c20d6e34983b4cfb9c05b4 (diff) | |
download | FreeBSD-src-e147a0c4ede93cc9e8a78357d38ea4c6183f45ae.zip FreeBSD-src-e147a0c4ede93cc9e8a78357d38ea4c6183f45ae.tar.gz |
This commit was generated by cvs2svn to compensate for changes in r80785,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/sendmail/libsmutil')
-rw-r--r-- | contrib/sendmail/libsmutil/safefile.c | 83 | ||||
-rw-r--r-- | contrib/sendmail/libsmutil/snprintf.c | 8 |
2 files changed, 6 insertions, 85 deletions
diff --git a/contrib/sendmail/libsmutil/safefile.c b/contrib/sendmail/libsmutil/safefile.c index ceee53a..3a757f3 100644 --- a/contrib/sendmail/libsmutil/safefile.c +++ b/contrib/sendmail/libsmutil/safefile.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers. + * Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 @@ -12,7 +12,7 @@ */ #ifndef lint -static char id[] = "@(#)$Id: safefile.c,v 8.81.4.7 2000/09/01 21:09:23 ca Exp $"; +static char id[] = "@(#)$Id: safefile.c,v 8.81.4.10 2001/07/20 04:19:36 gshapiro Exp $"; #endif /* ! lint */ #include <sendmail.h> @@ -660,10 +660,6 @@ safedirpath(fn, uid, gid, user, flags, level, offset) ** Same as open. */ -#ifndef O_ACCMODE -# define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif /* ! O_ACCMODE */ - int safeopen(fn, omode, cmode, sff) char *fn; @@ -735,81 +731,6 @@ safeopen(fn, omode, cmode, sff) return fd; } /* -** SAFEFOPEN -- do a file open with extra checking -** -** Parameters: -** fn -- the file name to open. -** omode -- the open-style mode flags. -** cmode -- the create-style mode flags. -** sff -- safefile flags. -** -** Returns: -** Same as fopen. -*/ - -FILE * -safefopen(fn, omode, cmode, sff) - char *fn; - int omode; - int cmode; - long sff; -{ - int fd; - int save_errno; - FILE *fp; - char *fmode; - - switch (omode & O_ACCMODE) - { - case O_RDONLY: - fmode = "r"; - break; - - case O_WRONLY: - if (bitset(O_APPEND, omode)) - fmode = "a"; - else - fmode = "w"; - break; - - case O_RDWR: - if (bitset(O_TRUNC, omode)) - fmode = "w+"; - else if (bitset(O_APPEND, omode)) - fmode = "a+"; - else - fmode = "r+"; - break; - - default: - syserr("554 5.3.5 safefopen: unknown omode %o", omode); - fmode = "x"; - } - fd = safeopen(fn, omode, cmode, sff); - if (fd < 0) - { - save_errno = errno; - if (tTd(44, 10)) - dprintf("safefopen: safeopen failed: %s\n", - errstring(errno)); - errno = save_errno; - return NULL; - } - fp = fdopen(fd, fmode); - if (fp != NULL) - return fp; - - save_errno = errno; - if (tTd(44, 10)) - { - dprintf("safefopen: fdopen(%s, %s) failed: omode=%x, sff=%lx, err=%s\n", - fn, fmode, omode, sff, errstring(errno)); - } - (void) close(fd); - errno = save_errno; - return NULL; -} -/* ** FILECHANGED -- check to see if file changed after being opened ** ** Parameters: diff --git a/contrib/sendmail/libsmutil/snprintf.c b/contrib/sendmail/libsmutil/snprintf.c index 9621a16..7a2aabc 100644 --- a/contrib/sendmail/libsmutil/snprintf.c +++ b/contrib/sendmail/libsmutil/snprintf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers. + * Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1997 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 @@ -12,7 +12,7 @@ */ #ifndef lint -static char id[] = "@(#)$Id: snprintf.c,v 8.27.16.2 2000/09/17 17:04:24 gshapiro Exp $"; +static char id[] = "@(#)$Id: snprintf.c,v 8.27.16.4 2001/07/20 04:19:37 gshapiro Exp $"; #endif /* ! lint */ #include <sendmail.h> @@ -86,10 +86,10 @@ sm_vsnprintf(str, count, fmt, args) sm_dopr( str, fmt, args ); if (count > 0) DoprEnd[0] = 0; - if (SnprfOverflow && tTd(57, 2)) + if (SnprfOverflow > 0 && tTd(57, 2)) dprintf("\nvsnprintf overflow, len = %ld, str = %s", (long) count, shortenstring(str, MAXSHORTSTR)); - return strlen(str); + return strlen(str) + SnprfOverflow; } /* |