SCCS-vsn: libexec/mail.local/mail.local.c 8.17
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)mail.local.c 8.16 (Berkeley) %G%";
+static char sccsid[] = "@(#)mail.local.c 8.17 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
#if __STDC__
#include <stdarg.h>
#if __STDC__
#include <stdarg.h>
struct stat fsb, sb;
struct passwd *pw;
int mbfd, nr, nw, off;
struct stat fsb, sb;
struct passwd *pw;
int mbfd, nr, nw, off;
char biffmsg[100], buf[8*1024], path[MAXPATHLEN];
off_t curoff;
char biffmsg[100], buf[8*1024], path[MAXPATHLEN];
off_t curoff;
+ /*
+ * Keep name reasonably short to avoid buffer overruns.
+ * This isn't necessary on BSD because of the proper
+ * definition of snprintf(), but it can cause problems
+ * on other systems.
+ * Also, clear out any bogus characters.
+ */
+
+ if (strlen(name) > 40)
+ name[40] = '\0';
+ for (p = name; *p != '\0'; p++)
+ {
+ if (!isascii(*p))
+ *p &= 0x7f;
+ else if (!isprint(*p))
+ *p = '.';
+ }
+
(void)snprintf(path, sizeof(path), "%s/%s", _PATH_MAILDIR, name);
/*
(void)snprintf(path, sizeof(path), "%s/%s", _PATH_MAILDIR, name);
/*
goto err1;
}
while ((nr = read(fd, buf, sizeof(buf))) > 0)
goto err1;
}
while ((nr = read(fd, buf, sizeof(buf))) > 0)
- for (off = 0; off < nr; nr -= nw, off += nw)
- if ((nw = write(mbfd, buf + off, nr)) < 0) {
+ for (off = 0; off < nr; off += nw)
+ if ((nw = write(mbfd, buf + off, nr - off)) < 0) {
e_to_sys(errno);
warn("%s: %s", path, strerror(errno));
goto err2;;
e_to_sys(errno);
warn("%s: %s", path, strerror(errno));
goto err2;;
+char lockname[MAXPATHLEN];
int locked = 0;
lockmbox(path)
int locked = 0;
lockmbox(path)