Deleted Added
sdiff udiff text old ( 125823 ) new ( 132946 )
full compact
1/*
2 * Copyright (c) 1998-2003 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
5 * Copyright (c) 1988, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * By using this file, you agree to the terms and conditions set
9 * forth in the LICENSE file which can be found at the top level of
10 * the sendmail distribution.
11 *
12 * $FreeBSD: head/contrib/sendmail/src/headers.c 125823 2004-02-14 21:58:08Z gshapiro $
13 */
14
15#include <sendmail.h>
16
17SM_RCSID("@(#)$Id: headers.c,v 8.266.4.9 2003/10/30 00:17:22 gshapiro Exp $")
18
19static size_t fix_mime_header __P((HDR *, ENVELOPE *));
20static int priencode __P((char *));
21static void put_vanilla_header __P((HDR *, char *, MCI *));
22
23/*
24** SETUPHEADERS -- initialize headers in symbol table
25**
26** Parameters:

--- 56 unchanged lines hidden (view full) ---

83 STAB *s;
84 struct hdrinfo *hi;
85 bool nullheader = false;
86 BITMAP256 mopts;
87
88 if (tTd(31, 6))
89 {
90 sm_dprintf("chompheader: ");
91 xputs(line);
92 sm_dprintf("\n");
93 }
94
95 headeronly = hdrp != NULL;
96 if (!headeronly)
97 hdrp = &e->e_header;
98
99 /* strip off options */

--- 187 unchanged lines hidden (view full) ---

287 ** If there is a check ruleset, verify it against the header.
288 */
289
290 if (bitset(pflag, CHHDR_CHECK))
291 {
292 int rscheckflags;
293 char *rs;
294
295 /* no ruleset? look for default */
296 rs = hi->hi_ruleset;
297 rscheckflags = RSF_COUNT;
298 if (!bitset(hi->hi_flags, H_FROM|H_RCPT))
299 rscheckflags |= RSF_UNSTRUCTURED;
300 if (rs == NULL)
301 {
302 s = stab("*", ST_HEADER, ST_FIND);
303 if (s != NULL)
304 {
305 rs = (&s->s_header)->hi_ruleset;
306 if (bitset((&s->s_header)->hi_flags,
307 H_STRIPCOMM))

--- 45 unchanged lines hidden (view full) ---

353 macdefine(&e->e_macro, A_TEMP,
354 macid("{currHeader}"), qval);
355 macdefine(&e->e_macro, A_TEMP,
356 macid("{hdr_name}"), fname);
357
358 (void) sm_snprintf(qval, sizeof qval, "%d", k);
359 macdefine(&e->e_macro, A_TEMP, macid("{hdrlen}"), qval);
360#if _FFR_HDR_TYPE
361 /*
362 ** XXX: h isn't set yet
363 ** If we really want to be precise then we have
364 ** to lookup the header (see below).
365 ** It's probably not worth the effort.
366 */
367
368 if (bitset(H_FROM, h->h_flags))
369 macdefine(&e->e_macro, A_PERM,
370 macid("{addr_type}"), "h s");
371 else if (bitset(H_RCPT, h->h_flags))
372 macdefine(&e->e_macro, A_PERM,
373 macid("{addr_type}"), "h r");
374 else
375#endif /* _FFR_HDR_TYPE */
376 macdefine(&e->e_macro, A_PERM,
377 macid("{addr_type}"), "h");
378 (void) rscheck(rs, fvalue, NULL, e, rscheckflags, 3,
379 NULL, e->e_id);

--- 82 unchanged lines hidden (view full) ---

462 strchr(fvalue, '<') != NULL || strchr(fvalue, ';') != NULL))
463 {
464 e->e_flags &= ~EF_OLDSTYLE;
465 }
466
467 return h->h_flags;
468}
469/*
470** ADDHEADER -- add a header entry to the end of the queue.
471**
472** This bypasses the special checking of chompheader.
473**
474** Parameters:
475** field -- the name of the header field.
476** value -- the value of the field.
477** flags -- flags to add to h_flags.

--- 9 unchanged lines hidden (view full) ---

487void
488addheader(field, value, flags, e)
489 char *field;
490 char *value;
491 int flags;
492 ENVELOPE *e;
493{
494 register HDR *h;
495 STAB *s;
496 HDR **hp;
497 HDR **hdrlist = &e->e_header;
498
499 /* find info struct */
500 s = stab(field, ST_HEADER, ST_FIND);
501
502 /* find current place in list -- keep back pointer? */
503 for (hp = hdrlist; (h = *hp) != NULL; hp = &h->h_link)
504 {
505 if (sm_strcasecmp(field, h->h_field) == 0)
506 break;
507 }
508
509 /* allocate space for new header */
510 h = (HDR *) sm_rpool_malloc_x(e->e_rpool, sizeof *h);
511 h->h_field = field;
512 h->h_value = sm_rpool_strdup_x(e->e_rpool, value);
513 h->h_link = *hp;
514 h->h_flags = flags;
515 if (s != NULL)
516 h->h_flags |= s->s_header.hi_flags;
517 clrbitmap(h->h_mflags);
518 h->h_macro = '\0';
519 *hp = h;
520}
521/*
522** HVALUE -- return value of a header.
523**
524** Only "real" fields (i.e., ones that have not been supplied
525** as a default) are used.
526**
527** Parameters:
528** field -- the field name.
529** header -- the header list.

--- 139 unchanged lines hidden (view full) ---

669
670 /* do early binding */
671 if (bitset(H_DEFAULT, h->h_flags) &&
672 !bitset(H_BINDLATE, h->h_flags))
673 {
674 if (tTd(32, 1))
675 {
676 sm_dprintf("(");
677 xputs(h->h_value);
678 sm_dprintf(") ");
679 }
680 expand(h->h_value, buf, sizeof buf, e);
681 if (buf[0] != '\0')
682 {
683 if (bitset(H_FROM, h->h_flags))
684 expand(crackaddr(buf, e),
685 buf, sizeof buf, e);
686 h->h_value = sm_rpool_strdup_x(e->e_rpool, buf);
687 h->h_flags &= ~H_DEFAULT;
688 }
689 }
690 if (tTd(32, 1))
691 {
692 xputs(h->h_value);
693 sm_dprintf("\n");
694 }
695
696 /* count the number of times it has been processed */
697 if (bitset(H_TRACE, h->h_flags))
698 hopcnt++;
699
700 /* send to this person if we so desire */

--- 25 unchanged lines hidden (view full) ---

726 p = "resent-message-id";
727 if (!bitset(EF_RESENT, e->e_flags))
728 p += 7;
729 if (sm_strcasecmp(h->h_field, p) == 0)
730 {
731 e->e_msgid = h->h_value;
732 while (isascii(*e->e_msgid) && isspace(*e->e_msgid))
733 e->e_msgid++;
734#if _FFR_MESSAGEID_MACRO
735 macdefine(&e->e_macro, A_PERM, macid("{msg_id}"),
736 e->e_msgid);
737#endif /* _FFR_MESSAGEID_MACRO */
738 }
739 }
740 if (tTd(32, 1))
741 sm_dprintf("----------------------------\n");
742
743 /* if we are just verifying (that is, sendmail -t -bv), drop out now */
744 if (OpMode == MD_VERIFY)
745 return;

--- 16 unchanged lines hidden (view full) ---

762 e->e_timeoutclass = TOC_URGENT;
763 if (full)
764 {
765 e->e_msgpriority = e->e_msgsize
766 - e->e_class * WkClassFact
767 + e->e_nrcpts * WkRecipFact;
768 }
769
770 /* message timeout priority */
771 p = hvalue("priority", e->e_header);
772 if (p != NULL)
773 {
774 /* (this should be in the configuration file) */
775 if (sm_strcasecmp(p, "urgent") == 0)
776 e->e_timeoutclass = TOC_URGENT;
777 else if (sm_strcasecmp(p, "normal") == 0)
778 e->e_timeoutclass = TOC_NORMAL;
779 else if (sm_strcasecmp(p, "non-urgent") == 0)
780 e->e_timeoutclass = TOC_NONURGENT;
781#if _FFR_QUEUERETURN_DSN
782 else if (bitset(EF_RESPONSE, e->e_flags))
783 e->e_timeoutclass = TOC_DSN;
784#endif /* _FFR_QUEUERETURN_DSN */
785 }
786#if _FFR_QUEUERETURN_DSN
787 else if (bitset(EF_RESPONSE, e->e_flags))
788 e->e_timeoutclass = TOC_DSN;
789#endif /* _FFR_QUEUERETURN_DSN */
790
791 /* date message originated */
792 p = hvalue("posted-date", e->e_header);
793 if (p == NULL)
794 p = hvalue("date", e->e_header);
795 if (p != NULL)
796 macdefine(&e->e_macro, A_PERM, 'a', p);
797

--- 437 unchanged lines hidden (view full) ---

1235 isascii(*--p) && isspace(*p))
1236 continue;
1237 p++;
1238 }
1239 for (q = addrhead; q < p; )
1240 {
1241 c = *q++;
1242 if (quoteit && c == '"')
1243 {
1244 SM_APPEND_CHAR('\\');
1245 SM_APPEND_CHAR(c);
1246 }
1247 else
1248 SM_APPEND_CHAR(c);
1249 }
1250 if (quoteit)
1251 {
1252 if (bp == &bufhead[1])
1253 bp--;
1254 else
1255 SM_APPEND_CHAR('"');
1256 while ((c = *p++) != ':')

--- 145 unchanged lines hidden (view full) ---

1402 buf[4]= '\0';
1403 sm_syslog(LOG_ALERT, e->e_id,
1404 "Dropped invalid comments from header address");
1405
1406 success:
1407 if (tTd(33, 1))
1408 {
1409 sm_dprintf("crackaddr=>`");
1410 xputs(buf);
1411 sm_dprintf("'\n");
1412 }
1413 return buf;
1414}
1415/*
1416** PUTHEADER -- put the header part of a message from the in-core copy
1417**
1418** Parameters:

--- 36 unchanged lines hidden (view full) ---

1455 for (h = hdr; h != NULL; h = h->h_link)
1456 {
1457 register char *p = h->h_value;
1458 char *q;
1459
1460 if (tTd(34, 11))
1461 {
1462 sm_dprintf(" %s: ", h->h_field);
1463 xputs(p);
1464 }
1465
1466 /* Skip empty headers */
1467 if (h->h_value == NULL)
1468 continue;
1469
1470 /* heuristic shortening of MIME fields to avoid MUA overflows */
1471 if (MaxMimeFieldLength > 0 &&

--- 337 unchanged lines hidden (view full) ---

1809 name = p;
1810 res = NULL;
1811 for (;;)
1812 {
1813 auto char *oldp;
1814 char pvpbuf[PSBUFSIZE];
1815
1816 res = prescan(p, oldstyle ? ' ' : ',', pvpbuf,
1817 sizeof pvpbuf, &oldp, NULL);
1818 p = oldp;
1819#if _FFR_IGNORE_BOGUS_ADDR
1820 /* ignore addresses that can't be parsed */
1821 if (res == NULL)
1822 {
1823 name = p;
1824 continue;
1825 }

--- 220 unchanged lines hidden ---