> On 21 Jan 2016, at 22:40, Edgar Pettijohn <ed...@pettijohn-web.com> wrote:
> 
> I've been getting the following in the logs for a couple of weeks now. I had 
> intended on upgrading to a current snapshot and testing, but I haven't had a 
> chance.  Has anyone else seen this? 
> 
> smtpd[8217]: smtp-in: session 25c5ca54fc7bce0c: connection from host 
> server.majorhosting.ru [205.234.232.6] established 
> spamd[28577]: spamd: connection from localhost [127.0.0.1]:7943 to port 783, 
> fd 6 
> smtpd[8217]: smtp-in: session 25c5ca54fc7bce0c: received invalid input: 500 
> 5.0.0: Line too long 
> smtpd[8217]: smtp-in: session 25c5ca54fc7bce0c: connection from host 
> server.majorhosting.ru [205.234.232.6] closed (client sent QUIT) 
> spamd[28577]: spamd: processing message 
> <1399008493.1859859723520628...@mutism.cliftbonze.com> for (unknown):506 
> smtpd[8217]: warn: pony -> inbound: pipe closed 
> smtpd[8217]: warn: filter "inbound" closed unexpectedly 
> smtpd[8217]: fatal: exiting 
> 
> 
> Thanks, 
> 
> Edgar 

Hi Edgar,

I have. I’m running 5.8 stable with a stock smtpd. 

I’ve hit two problems with it relating to the maximum line length. One is the 
RFC2822 limitation for any of the header lines, and the other one is just a 
general line length limit which is what I think you may have seen.

I’ve patched my own server to allow for longer lines (patch below). I’m not 
sure it’s applicable for general release, I found that it fixes the issue I’ve 
come across. 

Please note, LINE_MAX is defined in sys/syslimits.h and is set to 2048 - hence 
I’ve used my own constant. 

--- usr.sbin/smtpd/smtp_session.c       Tue Jan 20 17:37:54 2015
+++ /home/mike/src/smtp_session.c       Thu Aug  6 17:27:07 2015
@@ -53,6 +53,8 @@

#define APPEND_DOMAIN_BUFFER_SIZE       4096

+#define        LINE_MAX_LRG    9999
+
enum smtp_phase {
        PHASE_INIT = 0,
        PHASE_SETUP,
@@ -130,8 +132,8 @@ struct smtp_session {
        int                      phase;
        enum smtp_state          state;

-       char                     helo[LINE_MAX];
-       char                     cmd[LINE_MAX];
+       char                     helo[LINE_MAX_LRG];
+       char                     cmd[LINE_MAX_LRG];
        char                     username[LOGIN_NAME_MAX];

        struct envelope          evp;
@@ -493,7 +495,7 @@ smtp_session(struct listener *listener, int sock,

        if ((s = calloc(1, sizeof(*s))) == NULL)
                return (-1);
-       if (iobuf_init(&s->iobuf, LINE_MAX, LINE_MAX) == -1) {
+       if (iobuf_init(&s->iobuf, LINE_MAX_LRG, LINE_MAX_LRG) == -1) {  
                free(s);
                return (-1);
        }
@@ -1086,8 +1088,8 @@ smtp_io(struct io *io, int evt)
        case IO_DATAIN:
            nextline:
                line = iobuf_getline(&s->iobuf, &len);
-               if ((line == NULL && iobuf_len(&s->iobuf) >= LINE_MAX) ||
-                   (line && len >= LINE_MAX)) {
+               if ((line == NULL && iobuf_len(&s->iobuf) >= LINE_MAX_LRG) ||
+                   (line && len >= LINE_MAX_LRG)) {
                        s->flags |= SF_BADINPUT;
                        smtp_reply(s, "500 %s: Line too long",
                            esc_code(ESC_STATUS_PERMFAIL, ESC_OTHER_STATUS));
@@ -1586,7 +1588,7 @@ abort:
static void
smtp_rfc4954_auth_login(struct smtp_session *s, char *arg)
{
-       char            buf[LINE_MAX];
+       char            buf[LINE_MAX_LRG];

        switch (s->state) {
        case STATE_HELO:
@@ -1916,12 +1918,12 @@ smtp_reply(struct smtp_session *s, char *fmt, ...)
{
        va_list  ap;
        int      n;
-       char     buf[LINE_MAX], tmp[LINE_MAX];
+       char     buf[LINE_MAX_LRG], tmp[LINE_MAX_LRG];

        va_start(ap, fmt);
        n = vsnprintf(buf, sizeof buf, fmt, ap);
        va_end(ap);
-       if (n == -1 || n >= LINE_MAX)
+       if (n == -1 || n >= LINE_MAX_LRG)
                fatalx("smtp_reply: line too long");
        if (n < 4)
                fatalx("smtp_reply: response too short");


Best Regards,
mike

-- 
Michal Krzysztofowicz
http://antarcti.co/ | http://beautifulocean.org/


--
You received this mail because you are subscribed to misc@opensmtpd.org
To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org

Reply via email to