check for crlf in m_getfld2
authorPhilipp Takacs <philipp@bureaucracy.de>
Sat, 14 Jul 2018 09:24:36 +0000 (11:24 +0200)
committermarkus schnalke <meillo@marmaro.de>
Sun, 15 Jul 2018 11:31:07 +0000 (13:31 +0200)
now header fields witch lines 998 chars and crlf
are accepted.

h/mh.h
sbr/m_getfld2.c

diff --git a/h/mh.h b/h/mh.h
index 53b301e..20346b6 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -210,6 +210,7 @@ struct field {
        char *value;
        size_t valuelen;
        size_t alloclen;
        char *value;
        size_t valuelen;
        size_t alloclen;
+       boolean crlf;
 };
 
 /* m_getfld2() states */
 };
 
 /* m_getfld2() states */
index 954ed33..b9a618d 100644 (file)
@@ -62,7 +62,8 @@ m_getfld2(enum state s, struct field *f, FILE *msg)
                        }
                }
 
                        }
                }
 
-               if (nchars > NAMESZ) {
+               f->crlf = (nchars > 2 && tmpline[nchars-2] == '\r');
+               if (nchars > NAMESZ+1 || (!f->crlf && nchars > NAMESZ)) {
                        ret = LENERR2;
                }
 
                        ret = LENERR2;
                }
 
@@ -103,7 +104,7 @@ m_getfld2(enum state s, struct field *f, FILE *msg)
                                return IOERR2;
                        }
 
                                return IOERR2;
                        }
 
-                       if (nchars > NAMESZ) {
+                       if (nchars > NAMESZ+1 || (!f->crlf && nchars > NAMESZ)) {
                                ret = LENERR2;
                        }
 
                                ret = LENERR2;
                        }
 
@@ -145,6 +146,7 @@ m_getfld2(enum state s, struct field *f, FILE *msg)
                        }
                }
 
                        }
                }
 
+               f->crlf = (nchars > 2 && tmpline[nchars-2] == '\r');
                free(f->value);
                f->value = tmpline;
                f->valuelen = nchars;
                free(f->value);
                f->value = tmpline;
                f->valuelen = nchars;