diff -urNp -x '*.orig' sendmail-8.16.1.org/sendmail/collect.c sendmail-8.16.1/sendmail/collect.c --- sendmail-8.16.1.org/sendmail/collect.c 2020-05-19 21:54:33.000000000 +0200 +++ sendmail-8.16.1/sendmail/collect.c 2021-10-03 22:30:58.038924399 +0200 @@ -15,6 +15,8 @@ #include +#define MAXHDRZ 512 + static void eatfrom __P((char *volatile, ENVELOPE *)); static void collect_doheader __P((ENVELOPE *)); static SM_FILE_T *collect_dfopen __P((ENVELOPE *)); @@ -283,6 +285,7 @@ collect(fp, smtpmode, hdrp, e, rsetsize) register ENVELOPE *e; bool rsetsize; { + int hdrz = 0; register SM_FILE_T *df; bool ignrdot; int dbto; @@ -612,6 +615,16 @@ nextstate: mstate = MS_BODY; goto nextstate; } + + if (hdrz++>MAXHDRZ) + { + sm_syslog(LOG_NOTICE, e->e_id, + "excessive headers from %s during message collect", + CurHostName ? CurHostName : ""); + errno = 0; + usrerr("451 Stop this. You are lame."); + goto readdone; + } /* check for possible continuation line */ do