diff options
Diffstat (limited to 'contrib/sendmail/src/headers.c')
-rw-r--r-- | contrib/sendmail/src/headers.c | 71 |
1 files changed, 28 insertions, 43 deletions
diff --git a/contrib/sendmail/src/headers.c b/contrib/sendmail/src/headers.c index e57a91d..03472ac 100644 --- a/contrib/sendmail/src/headers.c +++ b/contrib/sendmail/src/headers.c @@ -12,12 +12,14 @@ */ #ifndef lint -static char id[] = "@(#)$Id: headers.c,v 8.203.4.10 2000/10/13 17:54:30 gshapiro Exp $"; +static char id[] = "@(#)$Id: headers.c,v 8.203.4.7 2000/08/22 21:50:36 gshapiro Exp $"; #endif /* ! lint */ +/* $FreeBSD$ */ + #include <sendmail.h> -static size_t fix_mime_header __P((char *)); +static bool fix_mime_header __P((char *)); static int priencode __P((char *)); static void put_vanilla_header __P((HDR *, char *, MCI *)); @@ -164,7 +166,7 @@ chompheader(line, pflag, hdrp, e) goto hse; } - setbitn(bitidx(*p), mopts); + setbitn(*p, mopts); cond = TRUE; p++; } @@ -344,8 +346,7 @@ 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, - NULL); + (void) rscheck(rs, fvalue, NULL, e, stripcom, TRUE, 4); } } @@ -1389,18 +1390,14 @@ putheader(mci, hdr, e, flags) wordinclass(h->h_field, macid("{checkMIMEFieldHeaders}", NULL))) { - size_t len; - - len = fix_mime_header(h->h_value); - if (len > 0) + if (fix_mime_header(h->h_value)) { sm_syslog(LOG_ALERT, e->e_id, - "Truncated MIME %s header due to field size (length = %ld) (possible attack)", - h->h_field, (unsigned long) len); + "Truncated MIME %s header due to field size (possible attack)", + h->h_field); if (tTd(34, 11)) - dprintf(" truncated MIME %s header due to field size (length = %ld) (possible attack)\n", - h->h_field, - (unsigned long) len); + dprintf(" truncated MIME %s header due to field size (possible attack)\n", + h->h_field); } } @@ -1408,19 +1405,15 @@ putheader(mci, hdr, e, flags) wordinclass(h->h_field, macid("{checkMIMETextHeaders}", NULL))) { - size_t len; - - len = strlen(h->h_value); - if (len > (size_t) MaxMimeHeaderLength) + if (strlen(h->h_value) > (size_t)MaxMimeHeaderLength) { h->h_value[MaxMimeHeaderLength - 1] = '\0'; sm_syslog(LOG_ALERT, e->e_id, - "Truncated long MIME %s header (length = %ld) (possible attack)", - h->h_field, (unsigned long) len); + "Truncated long MIME %s header (possible attack)", + h->h_field); if (tTd(34, 11)) - dprintf(" truncated long MIME %s header (length = %ld) (possible attack)\n", - h->h_field, - (unsigned long) len); + dprintf(" truncated long MIME %s header (possible attack)\n", + h->h_field); } } @@ -1428,19 +1421,14 @@ putheader(mci, hdr, e, flags) wordinclass(h->h_field, macid("{checkMIMEHeaders}", NULL))) { - size_t len; - - len = strlen(h->h_value); - if (shorten_rfc822_string(h->h_value, - MaxMimeHeaderLength)) + if (shorten_rfc822_string(h->h_value, MaxMimeHeaderLength)) { sm_syslog(LOG_ALERT, e->e_id, - "Truncated long MIME %s header (length = %ld) (possible attack)", - h->h_field, (unsigned long) len); + "Truncated long MIME %s header (possible attack)", + h->h_field); if (tTd(34, 11)) - dprintf(" truncated long MIME %s header (length = %ld) (possible attack)\n", - h->h_field, - (unsigned long) len); + dprintf(" truncated long MIME %s header (possible attack)\n", + h->h_field); } } @@ -1471,7 +1459,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(bitidx(h->h_macro), e) == NULL)) + macvalue(h->h_macro & 0377, e) == NULL)) { if (tTd(34, 11)) dprintf(" (skipped)\n"); @@ -1833,23 +1821,22 @@ copyheader(header) ** string -- the full header ** ** Returns: -** length of last offending field, 0 if all ok. +** TRUE if the header was modified, FALSE otherwise ** ** Side Effects: ** string modified in place */ -static size_t +static bool 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 0; + return FALSE; /* Split on each ';' */ while ((end = find_character(begin, ';')) != NULL) @@ -1859,11 +1846,9 @@ fix_mime_header(string) *end = '\0'; - len = strlen(begin); - /* Shorten individual parameter */ if (shorten_rfc822_string(begin, MaxMimeFieldLength)) - retlen = len; + modified = TRUE; /* Collapse the possibly shortened string with rest */ bp = begin + strlen(begin); @@ -1887,5 +1872,5 @@ fix_mime_header(string) /* Move past ';' */ begin = end + 1; } - return retlen; + return modified; } |