From: epg <> Date: Tue, 20 Aug 2002 05:46:34 +0000 (+0000) Subject: Include . X-Git-Url: https://diplodocus.org/git/mdeliver/commitdiff_plain/7e79aea9134f2eb4e2af85636ac0db5a6a8ec9d1?ds=sidebyside;hp=256a84cc849c0fc27a3547c13b23873685425360 Include . Define HOST_NAME_MAX if not set. Use it instead of 64 for gethostname(3). Create new macro TMPNAMLEN for declaring maildir filename strings. --- diff --git a/mdeliver.c b/mdeliver.c index d65214b..5dd5239 100644 --- a/mdeliver.c +++ b/mdeliver.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -18,7 +19,20 @@ #include #include -#define LEN_ULONG 40 /* holds 2^128 - 1 in decimal, plus '\0' */ +#if !defined(HOST_NAME_MAX) +#if defined MAXHOSTNAMELEN +#define HOST_NAME_MAX MAXHOSTNAMELEN +#else +#define HOST_NAME_MAX 64 +#endif +#endif + +/* holds 2^128 - 1 in decimal, plus '\0' */ +#define LEN_ULONG 40 + +/* 1 for '\0', 4 for "tmp/", HOST_NAME_MAX for the hostname, and two + * LEN_ULONGs for time and pid. */ +#define TMPNAMLEN 1 + 4 + HOST_NAME_MAX + LEN_ULONG + LEN_ULONG /* Write all of buf, even if write(2) is interrupted. */ static ssize_t @@ -46,7 +60,7 @@ full_write(int fd, const char *buf, size_t nbytes) static void deliver(char *maildir, char *newfn) { - char fn[80 + LEN_ULONG * 2], host[64]; + char fn[TMPNAMLEN], host[HOST_NAME_MAX + 1]; char *buildfn; /* used to build up the fn */ time_t now; struct tm *t; @@ -121,7 +135,7 @@ deliver(char *maildir, char *newfn) int main(int argc, char *argv[]) { - char newfn[80 + LEN_ULONG * 2]; + char newfn[TMPNAMLEN]; pid_t pid; FILE *errfile; char *fail;