]> git.netwichtig.de Git - user/henk/code/exim.git/blobdiff - src/src/sieve.c
Docs: note that log_selector only applies to mainlog
[user/henk/code/exim.git] / src / src / sieve.c
index f693ebf4e9de9421a8acf784ee9ec3d793c6d307..4793d5756c9a1a6f451a4e8d916b1b8d097d6b95 100644 (file)
@@ -2,9 +2,11 @@
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) Michael Haardt 2003 - 2015
- * Copyright (c) The Exim Maintainers 2016 - 2021
+/*
+ * Copyright (c) The Exim Maintainers 2016 - 2022
+ * Copyright (c) Michael Haardt 2003 - 2015
  * See the file NOTICE for conditions of use and distribution.
+ * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 /* This code was contributed by Michael Haardt. */
@@ -245,7 +247,7 @@ for (int pass = 0; pass <= 1; pass++)
     dst->length=0;
   else
     {
-    dst->character = store_get(dst->length+1, is_tainted(src->character)); /* plus one for \0 */
+    dst->character = store_get(dst->length+1, src->character); /* plus one for \0 */
     new=dst->character;
     }
   for (const uschar * start = src->character, * end = start + src->length;
@@ -437,23 +439,22 @@ if (*uri && *uri!='?')
       {
       gstring * g = string_catn(NULL, start, uri-start);
 
-      to.character = string_from_gstring(g);
-      to.length = g->ptr;
+      to.length = len_string_from_gstring(g, &to.character);
       if (uri_decode(&to)==-1)
         {
         filter->errmsg=US"Invalid URI encoding";
         return -1;
         }
-      new=store_get(sizeof(string_item), FALSE);
-      new->text = store_get(to.length+1, is_tainted(to.character));
+      new = store_get(sizeof(string_item), GET_UNTAINTED);
+      new->text = store_get(to.length+1, to.character);
       if (to.length) memcpy(new->text, to.character, to.length);
-      new->text[to.length]='\0';
-      new->next=*recipient;
-      *recipient=new;
+      new->text[to.length] = '\0';
+      new->next = *recipient;
+      *recipient = new;
       }
     else
       {
-      filter->errmsg=US"Missing addr-spec in URI";
+      filter->errmsg = US"Missing addr-spec in URI";
       return -1;
       }
     if (*uri=='%') uri+=3;
@@ -470,8 +471,7 @@ if (*uri=='?')
       {
       gstring * g = string_catn(NULL, start, uri-start);
 
-      hname.character = string_from_gstring(g);
-      hname.length = g->ptr;
+      hname.length = len_string_from_gstring(g, &hname.character);
       if (uri_decode(&hname)==-1)
         {
         filter->errmsg=US"Invalid URI encoding";
@@ -492,8 +492,7 @@ if (*uri=='?')
       {
       gstring * g = string_catn(NULL, start, uri-start);
 
-      hname.character = string_from_gstring(g);
-      hname.length = g->ptr;
+      hname.length = len_string_from_gstring(g, &hname.character);
       if (uri_decode(&hvalue)==-1)
         {
         filter->errmsg=US"Invalid URI encoding";
@@ -502,8 +501,8 @@ if (*uri=='?')
       }
     if (hname.length==2 && strcmpic(hname.character, US"to")==0)
       {
-      new=store_get(sizeof(string_item), FALSE);
-      new->text = store_get(hvalue.length+1, is_tainted(hvalue.character));
+      new=store_get(sizeof(string_item), GET_UNTAINTED);
+      new->text = store_get(hvalue.length+1, hvalue.character);
       if (hvalue.length) memcpy(new->text, hvalue.character, hvalue.length);
       new->text[hvalue.length]='\0';
       new->next=*recipient;
@@ -539,8 +538,7 @@ if (*uri=='?')
         g = string_catn(g, hvalue.character, hvalue.length);
         g = string_catn(g, CUS "\n", 1);
 
-       header->character = string_from_gstring(g);
-       header->length = g->ptr;
+       hname.length = len_string_from_gstring(g, &hname.character);
         }
       }
     if (*uri=='&') ++uri;
@@ -1480,10 +1478,7 @@ if (*filter->pc=='"') /* quoted string */
       ++filter->pc;
 
       if (g)
-       {
-       data->character = string_from_gstring(g);
-       data->length = g->ptr;
-       }
+       data->length = len_string_from_gstring(g, &data->character);
       else
        data->character = US"\0";
       /* that way, there will be at least one character allocated */
@@ -1567,10 +1562,7 @@ else if (Ustrncmp(filter->pc,CUS "text:",5)==0) /* multiline string */
 #endif
         {
        if (g)
-         {
-         data->character = string_from_gstring(g);
-         data->length = g->ptr;
-         }
+         data->length = len_string_from_gstring(g, &data->character);
        else
          data->character = US"\0";
        /* that way, there will be at least one character allocated */
@@ -1729,7 +1721,7 @@ if (*filter->pc=='[') /* string list */
       struct String *new;
 
       dataCapacity = dataCapacity ? dataCapacity * 2 : 4;
-      new = store_get(sizeof(struct String) * dataCapacity, FALSE);
+      new = store_get(sizeof(struct String) * dataCapacity, GET_UNTAINTED);
 
       if (d) memcpy(new,d,sizeof(struct String)*dataLength);
       d = new;
@@ -1767,7 +1759,7 @@ if (*filter->pc=='[') /* string list */
   }
 else /* single string */
   {
-  if (!(d=store_get(sizeof(struct String)*2, FALSE)))
+  if (!(d=store_get(sizeof(struct String)*2, GET_UNTAINTED)))
     return -1;
 
   m=parse_string(filter,&d[0]);
@@ -3073,7 +3065,7 @@ while (*filter->pc)
         if (!already)
           /* New notification, process it */
           {
-          struct Notification * sent = store_get(sizeof(struct Notification), FALSE);
+          struct Notification * sent = store_get(sizeof(struct Notification), GET_UNTAINTED);
           sent->method=method;
           sent->importance=importance;
           sent->message=message;
@@ -3212,9 +3204,9 @@ while (*filter->pc)
           }
         for (struct String * a = addresses; a->length != -1; ++a)
           {
-          string_item * new = store_get(sizeof(string_item), FALSE);
+          string_item * new = store_get(sizeof(string_item), GET_UNTAINTED);
 
-          new->text = store_get(a->length+1, is_tainted(a->character));
+          new->text = store_get(a->length+1, a->character);
           if (a->length) memcpy(new->text,a->character,a->length);
           new->text[a->length]='\0';
           new->next=aliases;
@@ -3301,7 +3293,7 @@ while (*filter->pc)
 
           if (subject.length==-1)
             {
-            uschar *subject_def;
+            uschar * subject_def;
 
             subject_def = expand_string(US"${if def:header_subject {true}{false}}");
             if (subject_def && Ustrcmp(subject_def,"true")==0)
@@ -3310,13 +3302,12 @@ while (*filter->pc)
 
               expand_header(&subject,&str_subject);
               g = string_catn(g, subject.character, subject.length);
-             subject.character = string_from_gstring(g);
-              subject.length = g->ptr;
+             subject.length = len_string_from_gstring(g, &subject.character);
               }
             else
               {
-              subject.character=US"Automated reply";
-              subject.length=Ustrlen(subject.character);
+              subject.character = US"Automated reply";
+              subject.length = Ustrlen(subject.character);
               }
             }
 
@@ -3327,7 +3318,7 @@ while (*filter->pc)
           addr->prop.ignore_error = TRUE;
           addr->next = *generated;
           *generated = addr;
-          addr->reply = store_get(sizeof(reply_item), FALSE);
+          addr->reply = store_get(sizeof(reply_item), GET_UNTAINTED);
           memset(addr->reply,0,sizeof(reply_item)); /* XXX */
           addr->reply->to = string_copy(sender_address);
           if (from.length==-1)