Skip to content

Commit

Permalink
Qsmtpd: add code to handle high hop count in BDAT mode, even if hops …
Browse files Browse the repository at this point in the history
…are not yet counted

This fixes one of 2 warnings here, the other one is an intentional #warning.
  • Loading branch information
DerDakon committed Aug 11, 2016
1 parent 5224dbf commit 8a2aa6c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions qsmtpd/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

size_t maxbytes; /* the maximum allowed size of message data */
static char datebuf[35] = ">; "; /* the date for the From- and Received-lines */
static const char *loop_logmsg = "mail loop}";
static const char *loop_netmsg = "554 5.4.6 too many hops, this message is looping\r\n";


static inline void
two_digit(char *buf, int num)
Expand Down Expand Up @@ -344,8 +347,8 @@ smtp_data(void)
if (flagr) {
if (!strncasecmp("Received:", linein.s, 9)) {
if (++hops > MAXHOPS) {
logreason = "mail loop}";
errmsg = "554 5.4.6 too many hops, this message is looping\r\n";
logreason = loop_logmsg;
errmsg = loop_netmsg;
goto loop_data;
}
} else if ((linein.len >= 20) && !strncmp("Delivered-To:", linein.s, 13)) {
Expand All @@ -364,7 +367,7 @@ smtp_data(void)

TAILQ_FOREACH(np, &head, entries) {
if (np->ok && !strcmp(linein.s + 14, np->to.s)) {
logreason = "mail loop}";
logreason = loop_logmsg;
errmsg = "554 5.4.6 message is looping, found a \"Delivered-To:\" line with one of the recipients\r\n";
goto loop_data;
}
Expand Down Expand Up @@ -664,6 +667,13 @@ smtp_bdat(void)
if (queuefd_hdr >= 0)
queue_reset();
freedata();
} else if (hops > MAXHOPS) {
log_recips(loop_logmsg);
freedata();
if (netwrite(loop_netmsg)) {
bdaterr = -errno;
} else
bdaterr = -EDONE;
} else {
/* This returns the size as given by the client. It has successfully been parsed as number.
* and the contents of this message do not really matter, so we can just reuse that. This
Expand Down

0 comments on commit 8a2aa6c

Please sign in to comment.