diff options
author | Gilles Chehade <gilles@poolp.org> | 2018-12-20 20:45:55 +0100 |
---|---|---|
committer | Gilles Chehade <gilles@poolp.org> | 2018-12-20 20:45:55 +0100 |
commit | b30211586ed5c50750b680941b6885ccab073c5e (patch) | |
tree | 18af3548d3934a602c281735213e3124d96bcd98 | |
parent | sync (diff) | |
download | OpenSMTPD-b30211586ed5c50750b680941b6885ccab073c5e.tar.xz OpenSMTPD-b30211586ed5c50750b680941b6885ccab073c5e.zip |
fix hostname issue in mail.maildir.c
-rw-r--r-- | smtpd/mail.maildir.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/smtpd/mail.maildir.c b/smtpd/mail.maildir.c index 7612a734..6352aa74 100644 --- a/smtpd/mail.maildir.c +++ b/smtpd/mail.maildir.c @@ -20,6 +20,7 @@ #include <sys/types.h> #include <sys/stat.h> +#include <sys/param.h> #include <ctype.h> #include <err.h> @@ -114,6 +115,7 @@ maildir_engine(const char *dirname, int junk) char extpath[PATH_MAX]; char subdir[PATH_MAX]; char filename[PATH_MAX]; + char hostname[MAXHOSTNAMELEN]; char tmp[PATH_MAX]; char new[PATH_MAX]; @@ -165,10 +167,13 @@ maildir_engine(const char *dirname, int junk) } } + if (gethostname(hostname, sizeof hostname) != 0) + (void)strlcpy(hostname, "localhost", sizeof hostname); + (void)snprintf(filename, sizeof filename, "%lld.%08x.%s", (long long int) time(NULL), arc4random(), - "localhost"); + hostname); (void)snprintf(tmp, sizeof tmp, "%s/tmp/%s", dirname, filename); |