aboutsummaryrefslogtreecommitdiffstats
path: root/driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'driver.c')
-rw-r--r--driver.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/driver.c b/driver.c
index cd632afd..220ce41a 100644
--- a/driver.c
+++ b/driver.c
@@ -1630,7 +1630,7 @@ int len; /* length of message */
flag forward; /* TRUE to forward */
{
int linelen;
- unsigned char buf[MSGBUFSIZE+1];
+ unsigned char buf[MSGBUFSIZE+4];
unsigned char *inbufp = buf;
flag issoftline = FALSE;
@@ -1638,7 +1638,7 @@ flag forward; /* TRUE to forward */
while (protocol->delimited || len > 0)
{
set_timeout(ctl->server.timeout);
- if ((linelen = SockRead(sock, inbufp, sizeof(buf)-1-(inbufp-buf)))==-1)
+ if ((linelen = SockRead(sock, inbufp, sizeof(buf)-4-(inbufp-buf)))==-1)
{
set_timeout(0);
if (ctl->mda)
@@ -1694,9 +1694,16 @@ flag forward; /* TRUE to forward */
/* ship out the text line */
if (forward && (!issoftline))
{
- int n = stuffline(ctl, buf);
+ int n;
inbufp = buf;
+ /* guard against very long lines */
+ buf[MSGBUFSIZE+1] = '\r';
+ buf[MSGBUFSIZE+2] = '\n';
+ buf[MSGBUFSIZE+3] = '\0';
+
+ n = stuffline(ctl, buf);
+
if (n < 0)
{
error(0, errno, "writing message text");