diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2001-01-21 22:21:43 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2001-01-21 22:21:43 +0000 |
commit | e804c25cafdf47cc91627155f1389c81fa997eca (patch) | |
tree | 115a2c1b4e339bc9c060e940ec6ae17826a0f7e0 /contrib/sendmail/src/headers.c | |
parent | c5e098efbef941858129b84a112a036d572ba53c (diff) | |
download | FreeBSD-src-e804c25cafdf47cc91627155f1389c81fa997eca.zip FreeBSD-src-e804c25cafdf47cc91627155f1389c81fa997eca.tar.gz |
Repair 8.11.2 merge conflicts
Diffstat (limited to 'contrib/sendmail/src/headers.c')
-rw-r--r-- | contrib/sendmail/src/headers.c | 69 |
1 files changed, 43 insertions, 26 deletions
diff --git a/contrib/sendmail/src/headers.c b/contrib/sendmail/src/headers.c index 03472ac..c45c00f 100644 --- a/contrib/sendmail/src/headers.c +++ b/contrib/sendmail/src/headers.c @@ -12,14 +12,14 @@ */ #ifndef lint -static char id[] = "@(#)$Id: headers.c,v 8.203.4.7 2000/08/22 21:50:36 gshapiro Exp $"; +static char id[] = "@(#)$Id: headers.c,v 8.203.4.10 2000/10/13 17:54:30 gshapiro Exp $"; #endif /* ! lint */ /* $FreeBSD$ */ #include <sendmail.h> -static bool fix_mime_header __P((char *)); +static size_t fix_mime_header __P((char *)); static int priencode __P((char *)); static void put_vanilla_header __P((HDR *, char *, MCI *)); @@ -166,7 +166,7 @@ chompheader(line, pflag, hdrp, e) goto hse; } - setbitn(*p, mopts); + setbitn(bitidx(*p), mopts); cond = TRUE; p++; } @@ -346,7 +346,8 @@ hse: free(sp); define(macid("{currHeader}", NULL), newstr(qval), e); define(macid("{hdr_name}", NULL), newstr(fname), e); - (void) rscheck(rs, fvalue, NULL, e, stripcom, TRUE, 4); + (void) rscheck(rs, fvalue, NULL, e, stripcom, TRUE, 4, + NULL); } } @@ -1390,14 +1391,18 @@ putheader(mci, hdr, e, flags) wordinclass(h->h_field, macid("{checkMIMEFieldHeaders}", NULL))) { - if (fix_mime_header(h->h_value)) + size_t len; + + len = fix_mime_header(h->h_value); + if (len > 0) { sm_syslog(LOG_ALERT, e->e_id, - "Truncated MIME %s header due to field size (possible attack)", - h->h_field); + "Truncated MIME %s header due to field size (length = %ld) (possible attack)", + h->h_field, (unsigned long) len); if (tTd(34, 11)) - dprintf(" truncated MIME %s header due to field size (possible attack)\n", - h->h_field); + dprintf(" truncated MIME %s header due to field size (length = %ld) (possible attack)\n", + h->h_field, + (unsigned long) len); } } @@ -1405,15 +1410,19 @@ putheader(mci, hdr, e, flags) wordinclass(h->h_field, macid("{checkMIMETextHeaders}", NULL))) { - if (strlen(h->h_value) > (size_t)MaxMimeHeaderLength) + size_t len; + + len = strlen(h->h_value); + if (len > (size_t) MaxMimeHeaderLength) { h->h_value[MaxMimeHeaderLength - 1] = '\0'; sm_syslog(LOG_ALERT, e->e_id, - "Truncated long MIME %s header (possible attack)", - h->h_field); + "Truncated long MIME %s header (length = %ld) (possible attack)", + h->h_field, (unsigned long) len); if (tTd(34, 11)) - dprintf(" truncated long MIME %s header (possible attack)\n", - h->h_field); + dprintf(" truncated long MIME %s header (length = %ld) (possible attack)\n", + h->h_field, + (unsigned long) len); } } @@ -1421,14 +1430,19 @@ putheader(mci, hdr, e, flags) wordinclass(h->h_field, macid("{checkMIMEHeaders}", NULL))) { - if (shorten_rfc822_string(h->h_value, MaxMimeHeaderLength)) + size_t len; + + len = strlen(h->h_value); + if (shorten_rfc822_string(h->h_value, + MaxMimeHeaderLength)) { sm_syslog(LOG_ALERT, e->e_id, - "Truncated long MIME %s header (possible attack)", - h->h_field); + "Truncated long MIME %s header (length = %ld) (possible attack)", + h->h_field, (unsigned long) len); if (tTd(34, 11)) - dprintf(" truncated long MIME %s header (possible attack)\n", - h->h_field); + dprintf(" truncated long MIME %s header (length = %ld) (possible attack)\n", + h->h_field, + (unsigned long) len); } } @@ -1459,7 +1473,7 @@ putheader(mci, hdr, e, flags) if (bitset(H_CHECK|H_ACHECK, h->h_flags) && !bitintersect(h->h_mflags, mci->mci_mailer->m_flags) && (h->h_macro == '\0' || - macvalue(h->h_macro & 0377, e) == NULL)) + macvalue(bitidx(h->h_macro), e) == NULL)) { if (tTd(34, 11)) dprintf(" (skipped)\n"); @@ -1821,22 +1835,23 @@ copyheader(header) ** string -- the full header ** ** Returns: -** TRUE if the header was modified, FALSE otherwise +** length of last offending field, 0 if all ok. ** ** Side Effects: ** string modified in place */ -static bool +static size_t fix_mime_header(string) char *string; { - bool modified = FALSE; char *begin = string; char *end; + size_t len = 0; + size_t retlen = 0; if (string == NULL || *string == '\0') - return FALSE; + return 0; /* Split on each ';' */ while ((end = find_character(begin, ';')) != NULL) @@ -1846,9 +1861,11 @@ fix_mime_header(string) *end = '\0'; + len = strlen(begin); + /* Shorten individual parameter */ if (shorten_rfc822_string(begin, MaxMimeFieldLength)) - modified = TRUE; + retlen = len; /* Collapse the possibly shortened string with rest */ bp = begin + strlen(begin); @@ -1872,5 +1889,5 @@ fix_mime_header(string) /* Move past ';' */ begin = end + 1; } - return modified; + return retlen; } |