X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fsrc%2Fheader.c;h=decd0cce69a107e43b141314a62381954295e566;hb=0d0ace194a602607133e569319652c7b7b8f0e22;hp=a9d8e599c1e7066541cd6619e3b135cb04133ce1;hpb=8523533c08c018ac4b750b0e0fab6cfe611e8a49;p=exim.git diff --git a/src/src/header.c b/src/src/header.c index a9d8e599c..decd0cce6 100644 --- a/src/src/header.c +++ b/src/src/header.c @@ -1,10 +1,8 @@ -/* $Cambridge: exim/src/src/header.c,v 1.2 2004/12/16 15:11:47 tom Exp $ */ - /************************************************* * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2004 */ +/* Copyright (c) University of Cambridge 1995 - 2016 */ /* See the file NOTICE for conditions of use and distribution. */ @@ -30,7 +28,7 @@ Returns: TRUE or FALSE */ BOOL -header_testname(header_line *h, uschar *name, int len, BOOL notdel) +header_testname(header_line *h, const uschar *name, int len, BOOL notdel) { uschar *tt; if (h->type == '*' && notdel) return FALSE; @@ -46,9 +44,9 @@ return *tt == ':'; header_testname() above. */ BOOL -header_testname_incomplete(header_line *h, uschar *name, int len, BOOL notdel) +header_testname_incomplete(header_line *h, const uschar *name, + int len, BOOL notdel) { -uschar *tt; if (h->type == '*' && notdel) return FALSE; if (h->text == NULL || strncmpic(h->text, name, len) != 0) return FALSE; return TRUE; @@ -93,7 +91,7 @@ Returns: nothing static void header_add_backend(BOOL after, uschar *name, BOOL topnot, int type, - char *format, va_list ap) + const char *format, va_list ap) { header_line *h, *new; header_line **hptr; @@ -119,7 +117,14 @@ if (name == NULL) else { hptr = &header_list; - h = header_list; + + /* header_list->text can be NULL if we get here between when the new + received header is allocated and when it is actually filled in. We want + that header to be first, so skip it for now. */ + + if (header_list->text == NULL) + hptr = &header_list->next; + h = *hptr; } } @@ -127,7 +132,7 @@ else { int len = Ustrlen(name); - /* Find the first non-deleted header witht the correct name. */ + /* Find the first non-deleted header with the correct name. */ for (hptr = &header_list; (h = *hptr) != NULL; hptr = &(h->next)) { @@ -207,7 +212,7 @@ Returns: nothing void header_add_at_position(BOOL after, uschar *name, BOOL topnot, int type, - char *format, ...) + const char *format, ...) { va_list ap; va_start(ap, format); @@ -232,7 +237,7 @@ Returns: nothing */ void -header_add(int type, char *format, ...) +header_add(int type, const char *format, ...) { va_list ap; va_start(ap, format); @@ -258,7 +263,7 @@ Returns: nothing */ void -header_remove(int occ, uschar *name) +header_remove(int occ, const uschar *name) { header_line *h; int hcount = 0; @@ -445,10 +450,11 @@ for (s = strings; s != NULL; s = s->next) va_start(ap, count); for (i = 0; i < count; i++) - { if (one_pattern_match(name, slen, has_addresses, va_arg(ap, uschar *))) + { + va_end(ap); return cond; - } + } va_end(ap); return !cond;