Index: contrib/dma/dma.h =================================================================== --- contrib/dma/dma.h (revision 333428) +++ contrib/dma/dma.h (working copy) @@ -60,6 +60,7 @@ #endif #define SMTP_PORT 25 /* Default SMTP port */ #define CON_TIMEOUT (5*60) /* Connection timeout per RFC5321 */ +#define MAX_LINE_RFC822 1000 /* Max line length per RFC822 */ #define STARTTLS 0x002 /* StartTLS support */ #define SECURETRANS 0x004 /* SSL/TLS in general */ Index: contrib/dma/local.c =================================================================== --- contrib/dma/local.c (revision 333428) +++ contrib/dma/local.c (working copy) @@ -126,7 +126,7 @@ deliver_local(struct qitem *it) { char fn[PATH_MAX+1]; - char line[1000]; + char line[MAX_LINE_RFC822]; const char *sender; const char *newline = "\n"; size_t linelen; @@ -207,7 +207,7 @@ while (!feof(it->mailf)) { if (fgets(line, sizeof(line), it->mailf) == NULL) break; - linelen = strlen(line); + linelen = strnlen(line, sizeof(line)); if (linelen == 0 || line[linelen - 1] != '\n') { syslog(LOG_CRIT, "local delivery failed: corrupted queue file"); snprintf(errmsg, sizeof(errmsg), "corrupted queue file"); Index: contrib/dma/mail.c =================================================================== --- contrib/dma/mail.c (revision 333428) +++ contrib/dma/mail.c (working copy) @@ -41,8 +41,6 @@ #include "dma.h" -#define MAX_LINE_RFC822 1000 - void bounce(struct qitem *it, const char *reason) { Index: contrib/dma/net.c =================================================================== --- contrib/dma/net.c (revision 333428) +++ contrib/dma/net.c (working copy) @@ -352,7 +352,7 @@ deliver_to_host(struct qitem *it, struct mx_hostentry *host) { struct authuser *a; - char line[1000]; + char line[MAX_LINE_RFC822]; size_t linelen; int fd, error = 0, do_auth = 0, res = 0; @@ -452,7 +452,7 @@ while (!feof(it->mailf)) { if (fgets(line, sizeof(line), it->mailf) == NULL) break; - linelen = strlen(line); + linelen = strnlen(line, sizeof(line)); if (linelen == 0 || line[linelen - 1] != '\n') { syslog(LOG_CRIT, "remote delivery failed: corrupted queue file"); snprintf(errmsg, sizeof(errmsg), "corrupted queue file");