summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
256a84c)
Define HOST_NAME_MAX if not set. Use it instead of 64 for
gethostname(3).
Create new macro TMPNAMLEN for declaring maildir filename strings.
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <time.h>
#include <unistd.h>
-#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
/* Write all of buf, even if write(2) is interrupted. */
static ssize_t
static void
deliver(char *maildir, char *newfn)
{
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;
char *buildfn; /* used to build up the fn */
time_t now;
struct tm *t;
int
main(int argc, char *argv[])
{
int
main(int argc, char *argv[])
{
- char newfn[80 + LEN_ULONG * 2];
pid_t pid;
FILE *errfile;
char *fail;
pid_t pid;
FILE *errfile;
char *fail;