diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2008-08-28 06:08:29 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2008-08-28 06:08:29 +0000 |
commit | b1e5c9c5e51c0569a82ee5838ed755e3c7bae94f (patch) | |
tree | 45eaace561ffa22220b192fa6cc9bd930b44ffb6 /contrib/sendmail/src/mci.c | |
parent | db890a1eb5b814a0367ca9de9f9a8f211f1231e7 (diff) | |
download | FreeBSD-src-b1e5c9c5e51c0569a82ee5838ed755e3c7bae94f.zip FreeBSD-src-b1e5c9c5e51c0569a82ee5838ed755e3c7bae94f.tar.gz |
Merge sendmail 8.14.3 into HEAD.
Note: As the first merge since the conversion to svn, it includes many
propset changes to get the proper svn:eol-style and svn:mime-type on the
files (as merged from the fixed up vendor/dist area).
MFC after: 3 days
Diffstat (limited to 'contrib/sendmail/src/mci.c')
-rw-r--r-- | contrib/sendmail/src/mci.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/contrib/sendmail/src/mci.c b/contrib/sendmail/src/mci.c index ef977440..2770117 100644 --- a/contrib/sendmail/src/mci.c +++ b/contrib/sendmail/src/mci.c @@ -9,12 +9,11 @@ * forth in the LICENSE file which can be found at the top level of * the sendmail distribution. * - * $FreeBSD$ */ #include <sendmail.h> -SM_RCSID("@(#)$Id: mci.c,v 8.218 2006/08/15 23:24:57 ca Exp $") +SM_RCSID("@(#)$Id: mci.c,v 8.221 2007/11/13 23:44:25 gshapiro Exp $") #if NETINET || NETINET6 # include <arpa/inet.h> @@ -1144,16 +1143,27 @@ mci_traverse_persistent(action, pathname) pathname, sm_errstring(errno)); return -1; } - len = sizeof(newpath) - MAXNAMLEN - 3; + + /* + ** Reserve space for trailing '/', at least one + ** character, and '\0' + */ + + len = sizeof(newpath) - 3; if (sm_strlcpy(newpath, pathname, len) >= len) { + int save_errno = errno; + if (tTd(56, 2)) sm_dprintf("mci_traverse: path \"%s\" too long", pathname); + (void) closedir(d); + errno = save_errno; return -1; } newptr = newpath + strlen(newpath); *newptr++ = '/'; + len = sizeof(newpath) - (newptr - newpath); /* ** repeat until no file has been removed @@ -1170,9 +1180,17 @@ mci_traverse_persistent(action, pathname) if (e->d_name[0] == '.') continue; - (void) sm_strlcpy(newptr, e->d_name, - sizeof(newpath) - - (newptr - newpath)); + if (sm_strlcpy(newptr, e->d_name, len) >= len) + { + /* Skip truncated copies */ + if (tTd(56, 4)) + { + *newptr = '\0'; + sm_dprintf("mci_traverse: path \"%s%s\" too long", + newpath, e->d_name); + } + continue; + } if (StopRequest) stop_sendmail(); |