$NetBSD: patch-ai,v 1.1.1.1 2007/04/17 10:16:53 jnemeth Exp $ --- sendmail/mci.c.orig 2005-07-12 22:27:44.000000000 +0000 +++ sendmail/mci.c @@ -20,6 +20,7 @@ SM_RCSID("@(#)$Id: mci.c,v 8.216 2005/07 #endif /* NETINET || NETINET6 */ #include +#include static int mci_generate_persistent_path __P((const char *, char *, int, bool)); @@ -717,7 +718,11 @@ mci_lock_host_statfile(mci) { int save_errno = errno; int retVal = EX_OK; +#if defined(PATH_MAX) + char fname[PATH_MAX]; +#else char fname[MAXPATHLEN]; +#endif if (HostStatDir == NULL || mci->mci_host == NULL) return EX_OK; @@ -1135,7 +1140,7 @@ mci_traverse_persistent(action, pathname pathname, sm_errstring(errno)); return -1; } - len = sizeof(newpath) - MAXNAMLEN - 3; + len = sizeof(newpath) - 2; /* enough space for '/' and NUL */ if (sm_strlcpy(newpath, pathname, len) >= len) { if (tTd(56, 2)) @@ -1145,6 +1150,7 @@ mci_traverse_persistent(action, pathname } newptr = newpath + strlen(newpath); *newptr++ = '/'; + len = sizeof(newpath) - (newptr - newpath); /* ** repeat until no file has been removed @@ -1161,9 +1167,8 @@ 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) + continue; if (StopRequest) stop_sendmail();