From 1fadbab6f4c38dbd151898ecc158b3dc28e87f16 Mon Sep 17 00:00:00 2001 From: Philipp Takacs Date: Sat, 14 Jul 2018 11:24:36 +0200 Subject: [PATCH] check for crlf in m_getfld2 now header fields witch lines 998 chars and crlf are accepted. --- h/mh.h | 1 + sbr/m_getfld2.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/h/mh.h b/h/mh.h index 53b301e..20346b6 100644 --- a/h/mh.h +++ b/h/mh.h @@ -210,6 +210,7 @@ struct field { char *value; size_t valuelen; size_t alloclen; + boolean crlf; }; /* m_getfld2() states */ diff --git a/sbr/m_getfld2.c b/sbr/m_getfld2.c index 954ed33..b9a618d 100644 --- a/sbr/m_getfld2.c +++ b/sbr/m_getfld2.c @@ -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; } @@ -103,7 +104,7 @@ m_getfld2(enum state s, struct field *f, FILE *msg) return IOERR2; } - if (nchars > NAMESZ) { + if (nchars > NAMESZ+1 || (!f->crlf && nchars > NAMESZ)) { 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; -- 1.7.10.4