[exim-cvs] constification

Página Inicial
Delete this message
Reply to this message
Autor: Exim Git Commits Mailing List
Data:  
Para: exim-cvs
Assunto: [exim-cvs] constification
Gitweb: https://git.exim.org/exim.git/commitdiff/fa1c8faf169384bebaa8d172f491574c45ae2aa4
Commit:     fa1c8faf169384bebaa8d172f491574c45ae2aa4
Parent:     b8e078953178c757578f2e104d9d2c822ae0943c
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Wed Nov 15 02:14:02 2023 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Wed Nov 15 02:14:02 2023 +0000


    constification
---
 src/exim_monitor/em_globals.c           |  2 +-
 src/exim_monitor/em_hdr.h               |  2 +-
 src/exim_monitor/em_queue.c             | 31 ++++++++--------
 src/src/acl.c                           | 12 +++----
 src/src/deliver.c                       | 53 +++++++++++++--------------
 src/src/exim.c                          | 46 ++++++++++++------------
 src/src/expand.c                        |  5 ++-
 src/src/functions.h                     | 20 +++++------
 src/src/globals.c                       | 32 ++++++++---------
 src/src/globals.h                       | 30 ++++++++--------
 src/src/local_scan.h                    | 10 +++---
 src/src/log.c                           |  5 ++-
 src/src/moan.c                          | 17 ++++-----
 src/src/queue.c                         | 11 +++---
 src/src/rda.c                           | 11 +++---
 src/src/receive.c                       | 10 +++---
 src/src/rewrite.c                       |  6 ++--
 src/src/route.c                         | 13 +++----
 src/src/routers/accept.c                |  6 ++--
 src/src/routers/redirect.c              |  5 ++-
 src/src/routers/rf_functions.h          |  2 +-
 src/src/routers/rf_get_errors_address.c | 15 ++++----
 src/src/spf.c                           |  3 +-
 src/src/spf.h                           |  2 +-
 src/src/spool_in.c                      |  9 +++--
 src/src/structs.h                       | 20 +++++------
 src/src/transport.c                     | 14 ++++----
 src/src/transports/appendfile.c         |  2 +-
 src/src/transports/pipe.c               | 21 +++++------
 src/src/transports/smtp.c               | 13 ++++---
 src/src/transports/smtp.h               |  2 +-
 src/src/verify.c                        | 63 ++++++++++++++++-----------------
 32 files changed, 246 insertions(+), 247 deletions(-)


diff --git a/src/exim_monitor/em_globals.c b/src/exim_monitor/em_globals.c
index cf9b1075e..3822746ba 100644
--- a/src/exim_monitor/em_globals.c
+++ b/src/exim_monitor/em_globals.c
@@ -204,7 +204,7 @@ recipient_item *recipients_list = NULL;
 int     recipients_list_max    = 0;
 BOOL    running_in_test_harness=FALSE;


-uschar *sender_address         = NULL;
+const uschar *sender_address    = NULL;
 uschar *sender_fullhost        = NULL;
 uschar *sender_helo_name       = NULL;
 uschar *sender_host_address    = NULL;
diff --git a/src/exim_monitor/em_hdr.h b/src/exim_monitor/em_hdr.h
index 61f390d2c..feffa6bfc 100644
--- a/src/exim_monitor/em_hdr.h
+++ b/src/exim_monitor/em_hdr.h
@@ -309,7 +309,7 @@ extern uschar *copystring(uschar *);
 extern void    create_dialog(uschar *, uschar *);
 extern void    create_stripchart(Widget, uschar *);
 extern void    debug(char *, ...);
-extern dest_item *find_dest(queue_item *, uschar *, int, BOOL);
+extern dest_item *find_dest(queue_item *, const uschar *, int, BOOL);
 extern queue_item *find_queue(uschar *, int, int);
 extern void    init(int, uschar **);
 extern void    menu_create(Widget, XEvent *, String *, Cardinal *);
diff --git a/src/exim_monitor/em_queue.c b/src/exim_monitor/em_queue.c
index 4c3d3fd18..c7c61a652 100644
--- a/src/exim_monitor/em_queue.c
+++ b/src/exim_monitor/em_queue.c
@@ -66,18 +66,16 @@ address is lowercased to start with, unless it begins with
 "*", which it does for error messages. */


dest_item *
-find_dest(queue_item *q, uschar *name, int action, BOOL caseless)
+find_dest(queue_item * q, const uschar * name, int action, BOOL caseless)
{
-dest_item *dd;
-dest_item **d = &(q->destinations);
+dest_item * dd;
+dest_item ** d = &q->destinations;

-while (*d != NULL)
+while (*d)
   {
   if ((caseless? strcmpic(name,(*d)->address) : Ustrcmp(name,(*d)->address))
         == 0)
     {
-    dest_item *ddd;
-
     if (action != dest_remove) return *d;
     dd = *d;
     *d = dd->next;
@@ -85,14 +83,12 @@ while (*d != NULL)


     /* Unset any parent pointers that were to this address */


-    for (ddd = q->destinations; ddd != NULL; ddd = ddd->next)
-      {
+    for (dest_item * ddd = q->destinations; ddd; ddd = ddd->next)
       if (ddd->parent == dd) ddd->parent = NULL;
-      }


     return NULL;
     }
-  d = &((*d)->next);
+  d = &(*d)->next;
   }


 if (action != dest_add) return NULL;
@@ -207,8 +203,9 @@ if it's there. */
 else
   {
   q->update_time = q->input_time = received_time.tv_sec;
-  if ((p = strstric(sender_address+1, qualify_domain, FALSE)) != NULL &&
-    *(--p) == '@') *p = 0;
+  /* deconst ok; strstric is actually safe */
+  if ((p = strstric(US sender_address+1, qualify_domain, FALSE)) != NULL &&
+    *--p == '@') *p = 0;
   }


 /* If we didn't read the whole header successfully, generate an error
@@ -279,10 +276,11 @@ been delivered, and removing visible names. */
 if (recipients_list)
   for (i = 0; i < recipients_count; i++)
     {
-    uschar * r = recipients_list[i].address;
+    const uschar * r = recipients_list[i].address;
     if (tree_search(tree_nonrecipients, r) == NULL)
       {
-      if ((p = strstric(r+1, qualify_domain, FALSE)) != NULL &&
+      /* deconst ok; strstric is actually safe */
+      if ((p = strstric(US r+1, qualify_domain, FALSE)) != NULL &&
         *(--p) == '@') *p = 0;
       (void)find_dest(q, r, dest_add, FALSE);
       }
@@ -663,13 +661,14 @@ if (recipients_list)
   for (i = 0; i < recipients_count; i++)
     {
     uschar * pp;
-    uschar * r = recipients_list[i].address;
+    const uschar * r = recipients_list[i].address;
     tree_node * node;


     if (!(node = tree_search(tree_nonrecipients, r)))
       node = tree_search(tree_nonrecipients, string_copylc(r));


-    if ((pp = strstric(r+1, qualify_domain, FALSE)) && *(--pp) == '@')
+    /* deconst ok; strstric is actually safe */
+    if ((pp = strstric(US r+1, qualify_domain, FALSE)) && *(--pp) == '@')
        *pp = 0;
     if (!node)
       (void)find_dest(p, r, dest_add, FALSE);
diff --git a/src/src/acl.c b/src/src/acl.c
index cdf60bbb8..9223fcec8 100644
--- a/src/src/acl.c
+++ b/src/src/acl.c
@@ -1711,10 +1711,10 @@ BOOL no_details = FALSE;
 BOOL success_on_redirect = FALSE;
 BOOL quota = FALSE;
 int quota_pos_cache = QUOTA_POS_DEFAULT, quota_neg_cache = QUOTA_NEG_DEFAULT;
-address_item *sender_vaddr = NULL;
-uschar *verify_sender_address = NULL;
-uschar *pm_mailfrom = NULL;
-uschar *se_mailfrom = NULL;
+address_item * sender_vaddr = NULL;
+const uschar * verify_sender_address = NULL;
+uschar * pm_mailfrom = NULL;
+uschar * se_mailfrom = NULL;


 /* Some of the verify items have slash-separated options; some do not. Diagnose
 an error if options are given for items that don't expect them.
@@ -4713,8 +4713,8 @@ Returns:       OK         access is granted by an ACCEPT verb
 int acl_where = ACL_WHERE_UNKNOWN;


 int
-acl_check(int where, uschar *recipient, uschar *s, uschar **user_msgptr,
-  uschar **log_msgptr)
+acl_check(int where, const uschar * recipient, uschar * s,
+  uschar ** user_msgptr, uschar ** log_msgptr)
 {
 int rc;
 address_item adb;
diff --git a/src/src/deliver.c b/src/src/deliver.c
index 9d459167e..e96733f73 100644
--- a/src/src/deliver.c
+++ b/src/src/deliver.c
@@ -27,7 +27,7 @@ typedef struct pardata {
   int transport_count;         /* returned transport count value */
   BOOL done;                   /* no more data needed */
   uschar *msg;                 /* error message */
-  uschar *return_path;         /* return_path for these addresses */
+  const uschar *return_path;   /* return_path for these addresses */
 } pardata;


/* Values for the process_recipients variable */
@@ -77,7 +77,7 @@ static pardata *parlist = NULL;
static struct pollfd *parpoll;
static int return_count;
static uschar *frozen_info = US"";
-static uschar *used_return_path = NULL;
+static const uschar * used_return_path = NULL;



@@ -144,7 +144,7 @@ Returns:      a pointer to an initialized address_item
 */


 address_item *
-deliver_make_addr(uschar *address, BOOL copy)
+deliver_make_addr(const uschar * address, BOOL copy)
 {
 address_item * addr = store_get(sizeof(address_item), GET_UNTAINTED);
 *addr = address_defaults;
@@ -575,7 +575,7 @@ Returns:    TRUE or FALSE
 */


 static BOOL
-same_strings(uschar *one, uschar *two)
+same_strings(const uschar * one, const uschar * two)
 {
 if (one == two) return TRUE;   /* Includes the case where both NULL */
 if (!one || !two) return FALSE;
@@ -898,7 +898,7 @@ void
 msg_event_raise(const uschar * event, const address_item * addr)
 {
 const uschar * save_domain = deliver_domain;
-uschar * save_local =  deliver_localpart;
+const uschar * save_local =  deliver_localpart;
 const uschar * save_host = deliver_host;
 const uschar * save_address = deliver_host_address;
 const int      save_port =   deliver_host_port;
@@ -950,13 +950,13 @@ router_name = transport_name = NULL;
 *        Generate local part for logging         *
 *************************************************/


-static uschar *
-string_get_lpart_sub(const address_item * addr, uschar * s)
+static const uschar *
+string_get_lpart_sub(const address_item * addr, const uschar * s)
 {
 #ifdef SUPPORT_I18N
 if (testflag(addr, af_utf8_downcvt))
   {
-  uschar * t = string_localpart_utf8_to_alabel(s, NULL);
+  const uschar * t = string_localpart_utf8_to_alabel(s, NULL);
   return t ? t : s;    /* t is NULL on a failed conversion */
   }
 #endif
@@ -975,7 +975,7 @@ Returns:      the new value of the buffer pointer
 static gstring *
 string_get_localpart(address_item * addr, gstring * yield)
 {
-uschar * s;
+const uschar * s;


 if (testflag(addr, af_include_affixes) && (s = addr->prefix))
   yield = string_cat(yield, string_get_lpart_sub(addr, s));
@@ -5086,7 +5086,7 @@ Returns:    OK
 int
 deliver_split_address(address_item * addr)
 {
-uschar * address = addr->address;
+const uschar * address = addr->address;
 uschar * domain;
 uschar * t;
 int len;
@@ -5103,7 +5103,7 @@ where they are locally interpreted. [The new draft "821" is more explicit on
 this, Jan 1999.] We know the syntax is valid, so this can be done by simply
 removing quoting backslashes and any unquoted doublequotes. */


-t = addr->cc_local_part = store_get(len+1, address);
+addr->cc_local_part = t = store_get(len+1, address);
 while(len-- > 0)
   {
   int c = *address++;
@@ -5115,7 +5115,7 @@ while(len-- > 0)
     }
   else *t++ = c;
   }
-*t = 0;
+*t = '\0';


/* We do the percent hack only for those domains that are listed in
percent_hack_domains. A loop is required, to copy with multiple %-hacks. */
@@ -5123,8 +5123,8 @@ percent_hack_domains. A loop is required, to copy with multiple %-hacks. */
if (percent_hack_domains)
{
int rc;
- uschar *new_address = NULL;
- uschar *local_part = addr->cc_local_part;
+ uschar * new_address = NULL;
+ const uschar * local_part = addr->cc_local_part;

deliver_domain = addr->domain; /* set $domain */

@@ -5261,12 +5261,12 @@ Returns:       TRUE if the address is not hidden
 */


static BOOL
-print_address_information(address_item *addr, FILE *f, uschar *si, uschar *sc,
- uschar *se)
+print_address_information(address_item * addr, FILE * f, uschar * si,
+ uschar * sc, uschar * se)
{
BOOL yield = TRUE;
-uschar *printed = US"";
-address_item *ancestor = addr;
+const uschar * printed = US"";
+address_item * ancestor = addr;
while (ancestor->parent) ancestor = ancestor->parent;

fprintf(f, "%s", CS si);
@@ -5281,8 +5281,8 @@ else if (!testflag(addr, af_pfr) || !addr->parent)

else
{
- uschar *s = addr->address;
- uschar *ss;
+ const uschar * s = addr->address;
+ const uschar * ss;

if (addr->address[0] == '>') { ss = US"mail"; s++; }
else if (addr->address[0] == '|') ss = US"pipe";
@@ -5296,7 +5296,7 @@ fprintf(f, "%s", CS string_printing(printed));

 if (ancestor != addr)
   {
-  uschar *original = ancestor->onetime_parent;
+  const uschar * original = ancestor->onetime_parent;
   if (!original) original= ancestor->address;
   if (strcmpic(original, printed) != 0)
     fprintf(f, "%s(%sgenerated from %s)", sc,
@@ -6973,7 +6973,7 @@ else if (system_filter && process_recipients != RECIP_FAIL_TIMEOUT)


         if (!p->transport)
           {
-          address_item *badp = p;
+          address_item * badp = p;
           p = p->next;
           if (!addr_last) addr_new = p; else addr_last->next = p;
           badp->local_part = badp->address;   /* Needed for log line */
@@ -7114,9 +7114,10 @@ if (process_recipients != RECIP_IGNORE)
 #ifndef DISABLE_EVENT
       if (process_recipients != RECIP_ACCEPT && event_action)
     {
-    uschar * save_local =  deliver_localpart;
+    const uschar * save_local =  deliver_localpart;
     const uschar * save_domain = deliver_domain;
-    uschar * addr = new->address, * errmsg = NULL;
+    const uschar * addr = new->address;
+    uschar * errmsg = NULL;
     int start, end, dom;


     if (!parse_extract_address(addr, &errmsg, &start, &end, &dom, TRUE))
@@ -8365,7 +8366,7 @@ else if (addr_defer != (address_item *)(+1))


       for (i = 0; i < recipients_count; i++)
         {
-        uschar *r = recipients_list[i].address;
+        const uschar * r = recipients_list[i].address;
         if (Ustrcmp(otaddr->onetime_parent, r) == 0) t = i;
         if (Ustrcmp(otaddr->address, r) == 0) break;
         }
@@ -8393,7 +8394,7 @@ else if (addr_defer != (address_item *)(+1))


     if (sender_address[0])
       {
-      uschar * s = addr->prop.errors_address;
+      const uschar * s = addr->prop.errors_address;
       if (!s) s = sender_address;
       if (Ustrstr(recipients, s) == NULL)
     recipients = string_sprintf("%s%s%s", recipients,
diff --git a/src/src/exim.c b/src/src/exim.c
index 14c057f40..4473373b3 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -1379,17 +1379,15 @@ Argument:    the local part
 Returns:     the local part, quoted if necessary
 */


-uschar *
-local_part_quote(uschar *lpart)
+const uschar *
+local_part_quote(const uschar * lpart)
{
BOOL needs_quote = FALSE;
gstring * g;

-for (uschar * t = lpart; !needs_quote && *t != 0; t++)
-  {
+for (const uschar * t = lpart; !needs_quote && *t; t++)
   needs_quote = !isalnum(*t) && strchr("!#$%&'*+-/=?^_`{|}~", *t) == NULL &&
     (*t != '.' || t == lpart || t[1] == 0);
-  }


if (!needs_quote) return lpart;

@@ -1397,8 +1395,8 @@ g = string_catn(NULL, US"\"", 1);

 for (;;)
   {
-  uschar *nq = US Ustrpbrk(lpart, "\\\"");
-  if (nq == NULL)
+  uschar * nq = US Ustrpbrk(lpart, "\\\"");
+  if (!nq)
     {
     g = string_cat(g, lpart);
     break;
@@ -1809,20 +1807,20 @@ BOOL verify_address_mode = FALSE;
 BOOL verify_as_sender = FALSE;
 BOOL rcpt_verify_quota = FALSE;
 BOOL version_printed = FALSE;
-const uschar *alias_arg = NULL;
-const uschar *called_as = US"";
-const uschar *cmdline_syslog_name = NULL;
-const uschar *start_queue_run_id = NULL;
-const uschar *stop_queue_run_id = NULL;
-const uschar *expansion_test_message = NULL;
-const uschar *ftest_domain = NULL;
-const uschar *ftest_localpart = NULL;
-const uschar *ftest_prefix = NULL;
-const uschar *ftest_suffix = NULL;
-uschar *log_oneline = NULL;
-const uschar *malware_test_file = NULL;
-uschar *real_sender_address;
-uschar *originator_home = US"/";
+const uschar * alias_arg = NULL;
+const uschar * called_as = US"";
+const uschar * cmdline_syslog_name = NULL;
+const uschar * start_queue_run_id = NULL;
+const uschar * stop_queue_run_id = NULL;
+const uschar * expansion_test_message = NULL;
+const uschar * ftest_domain = NULL;
+const uschar * ftest_localpart = NULL;
+const uschar * ftest_prefix = NULL;
+const uschar * ftest_suffix = NULL;
+uschar * log_oneline = NULL;
+const uschar * malware_test_file = NULL;
+const uschar * real_sender_address;
+uschar * originator_home = US"/";
 size_t sz;


 struct passwd *pw;
@@ -2844,7 +2842,11 @@ on the second character (the one after '-'), to save some effort. */
         if (i+1 < argc) argrest = argv[++i]; else { badarg = TRUE; break; }
       (void) exim_str_fail_toolong(argrest, EXIM_DISPLAYMAIL_MAX, "-f");
       if (!*argrest)
-        *(sender_address = store_get(1, GET_UNTAINTED)) = '\0';  /* Ensure writeable memory */
+    {
+        uschar * s = store_get(1, GET_UNTAINTED);    /* Ensure writeable memory */
+        *s = '\0';
+        sender_address = s;
+    }
       else
         {
         const uschar * temp = argrest + Ustrlen(argrest) - 1;
diff --git a/src/src/expand.c b/src/src/expand.c
index 40cc8d73a..9a88d38ca 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -1804,20 +1804,19 @@ return g;
 /* A recipients list is available only during system message filtering,
 during ACL processing after DATA, and while expanding pipe commands
 generated from a system filter, but not elsewhere.  Note that this does
-not check for comman in the elements, and uses comma-space as seperator -
+not check for commas in the elements, and uses comma-space as seperator -
 so cannot be used as an exim list as-is. */


static uschar *
fn_recipients(void)
{
-uschar * s;
gstring * g = NULL;

if (!f.enable_dollar_recipients) return NULL;

 for (int i = 0; i < recipients_count; i++)
   {
-  s = recipients_list[i].address;
+  const uschar * s = recipients_list[i].address;
   g = string_append2_listele_n(g, US", ", s, Ustrlen(s));
   }
 gstring_release_unused(g);
diff --git a/src/src/functions.h b/src/src/functions.h
index ba4fd215c..74cd15424 100644
--- a/src/src/functions.h
+++ b/src/src/functions.h
@@ -100,7 +100,7 @@ extern int     tlsa_lookup(const host_item *, dns_answer *, BOOL);
 /* Everything else... */


 extern acl_block *acl_read(uschar *(*)(void), uschar **);
-extern int     acl_check(int, uschar *, uschar *, uschar **, uschar **);
+extern int     acl_check(int, const uschar *, uschar *, uschar **, uschar **);
 extern uschar *acl_current_verb(void);
 extern int     acl_eval(int, uschar *, uschar **, uschar **);
 extern uschar *acl_standalone_setvar(const uschar *);
@@ -216,7 +216,7 @@ extern void    decode_bits(unsigned int *, size_t, int *,
                const uschar *, bit_table *, int, uschar *, int);
 extern void    delete_pid_file(void);
 extern void    deliver_local(address_item *, BOOL);
-extern address_item *deliver_make_addr(uschar *, BOOL);
+extern address_item *deliver_make_addr(const uschar *, BOOL);
 extern void    delivery_log(int, address_item *, int, uschar *);
 extern int     deliver_message(const uschar *, BOOL, BOOL);
 extern void    deliver_msglog(const char *, ...) PRINTF_FUNCTION(1,2);
@@ -335,7 +335,7 @@ extern int     ip_streamsocket(const uschar *, uschar **, int, host_item *);


 extern int     ipv6_nmtoa(int *, uschar *);


-extern uschar *local_part_quote(uschar *);
+extern const uschar *local_part_quote(const uschar *);
 extern int     log_open_as_exim(const uschar * const);
 extern void    log_close_all(void);


@@ -375,11 +375,11 @@ extern ssize_t mime_decode_base64(FILE *, FILE *, uschar *);
 extern int     mime_regex(const uschar **, BOOL);
 extern void    mime_set_anomaly(int);
 #endif
-extern uschar *moan_check_errorcopy(uschar *);
+extern uschar *moan_check_errorcopy(const uschar *);
 extern BOOL    moan_skipped_syntax_errors(uschar *, error_block *, uschar *,
                  BOOL, uschar *);
 extern void    moan_smtp_batch(uschar *, const char *, ...) PRINTF_FUNCTION(2,3);
-extern BOOL    moan_send_message(uschar *, int, error_block *eblock,
+extern BOOL    moan_send_message(const uschar *, int, error_block *eblock,
          header_line *, FILE *, uschar *);
 extern void    moan_tell_someone(uschar *, address_item *,
                  const uschar *, const char *, ...) PRINTF_FUNCTION(4,5);
@@ -440,7 +440,7 @@ extern void    readconf_save_config(const uschar *);
 extern void    read_message_body(BOOL);
 extern void    receive_bomb_out(uschar *, uschar *) NORETURN;
 extern BOOL    receive_check_fs(int);
-extern BOOL    receive_check_set_sender(uschar *);
+extern BOOL    receive_check_set_sender(const uschar *);
 extern BOOL    receive_msg(BOOL);
 extern int_eximarith_t receive_statvfs(BOOL, int *);
 extern void    receive_swallow_smtp(void);
@@ -636,7 +636,7 @@ extern BOOL    transport_pass_socket(const uschar *, const uschar *, const uscha
             , unsigned, unsigned, unsigned
 #endif
             );
-extern uschar *transport_rcpt_address(address_item *, BOOL);
+extern const uschar *transport_rcpt_address(address_item *, BOOL);
 extern BOOL    transport_set_up_command(const uschar ***, const uschar *,
          unsigned, int, address_item *, const uschar *, uschar **);
 extern void    transport_update_waiting(host_item *, uschar *);
@@ -644,7 +644,7 @@ extern BOOL    transport_write_block(transport_ctx *, uschar *, int, BOOL);
 extern void    transport_write_reset(int);
 extern BOOL    transport_write_string(int, const char *, ...);
 extern BOOL    transport_headers_send(transport_ctx *,
-                 BOOL (*)(transport_ctx *, uschar *, int));
+                 BOOL (*)(transport_ctx *, const uschar *, int));
 extern gstring * transport_show_supported(gstring *);
 extern BOOL    transport_write_message(transport_ctx *, int);
 extern void    tree_add_duplicate(const uschar *, address_item *);
@@ -679,7 +679,7 @@ extern int     verify_check_notblind(BOOL);
 extern int     verify_check_given_host(const uschar **, const host_item *);
 extern int     verify_check_this_host(const uschar **, unsigned int *,
              const uschar*, const uschar *, const uschar **);
-extern address_item *verify_checked_sender(uschar *);
+extern address_item *verify_checked_sender(const uschar *);
 extern void    verify_get_ident(int);
 extern void    verify_quota(uschar *);
 extern int     verify_quota_call(const uschar *, int, int, uschar **);
@@ -687,7 +687,7 @@ extern BOOL    verify_sender(int *, uschar **);
 extern BOOL    verify_sender_preliminary(int *, uschar **);
 extern void    version_init(void);


-extern BOOL    write_chunk(transport_ctx *, uschar *, int);
+extern BOOL    write_chunk(transport_ctx *, const uschar *, int);
 extern ssize_t write_to_fd_buf(int, const uschar *, size_t);
 extern uschar *wrap_header(const uschar *, unsigned, unsigned, const uschar *, unsigned);


diff --git a/src/src/globals.c b/src/src/globals.c
index 46ca72f20..bb5bd6b1a 100644
--- a/src/src/globals.c
+++ b/src/src/globals.c
@@ -610,8 +610,8 @@ address_item address_defaults = {
}
};

-uschar *address_file           = NULL;
-uschar *address_pipe           = NULL;
+const uschar *address_file           = NULL;
+const uschar *address_pipe           = NULL;
 tree_node *addresslist_anchor  = NULL;
 int     addresslist_count      = 0;
 gid_t  *admin_groups           = NULL;
@@ -683,7 +683,7 @@ int     body_linecount         = 0;
 int     body_zerocount         = 0;
 uschar *bounce_message_file    = NULL;
 uschar *bounce_message_text    = NULL;
-uschar *bounce_recipient       = NULL;
+const uschar *bounce_recipient = NULL;
 int     bounce_return_linesize_limit = 998;
 int     bounce_return_size_limit = 100*1024;
 uschar *bounce_sender_authentication = NULL;
@@ -842,14 +842,14 @@ const uschar *deliver_host_address = NULL;
 int     deliver_host_port      = 0;
 uschar *deliver_in_buffer      = NULL;
 ino_t   deliver_inode          = 0;
-uschar *deliver_localpart      = NULL;
+const uschar *deliver_localpart= NULL;
 uschar *deliver_localpart_data = NULL;
-uschar *deliver_localpart_orig = NULL;
-uschar *deliver_localpart_parent = NULL;
-uschar *deliver_localpart_prefix = NULL;
-uschar *deliver_localpart_prefix_v = NULL;
-uschar *deliver_localpart_suffix = NULL;
-uschar *deliver_localpart_suffix_v = NULL;
+const uschar *deliver_localpart_orig = NULL;
+const uschar *deliver_localpart_parent = NULL;
+const uschar *deliver_localpart_prefix = NULL;
+const uschar *deliver_localpart_prefix_v = NULL;
+const uschar *deliver_localpart_suffix = NULL;
+const uschar *deliver_localpart_suffix_v = NULL;
 uschar *deliver_out_buffer     = NULL;
 int     deliver_queue_load_max = -1;
 address_item  *deliver_recipients = NULL;
@@ -1276,8 +1276,8 @@ tree_node *ratelimiters_cmd    = NULL;
 tree_node *ratelimiters_conn   = NULL;
 tree_node *ratelimiters_mail   = NULL;
 uschar *raw_active_hostname    = NULL;
-uschar *raw_sender             = NULL;
-uschar **raw_recipients        = NULL;
+const uschar *raw_sender       = NULL;
+const uschar **raw_recipients  = NULL;
 int     raw_recipients_count   = 0;


 int     rcpt_count             = 0;
@@ -1289,7 +1289,7 @@ int     receive_linecount      = 0;
 int     receive_messagecount   = 0;
 int     receive_timeout        = 0;
 int     received_count         = 0;
-uschar *received_for           = NULL;
+const uschar *received_for     = NULL;


 /*  This is the default text for Received headers generated by Exim. The
 date  will be automatically added on the end. */
@@ -1348,7 +1348,7 @@ int     retry_data_expire      = 7*24*60*60;
 int     retry_interval_max     = 24*60*60;
 int     retry_maximum_timeout  = 0;        /* set from retry config */
 retry_config  *retries         = NULL;
-uschar *return_path            = NULL;
+const uschar *return_path            = NULL;
 int     rewrite_existflags     = 0;
 uschar *rfc1413_hosts          = US"@[]";
 int     rfc1413_query_timeout  = 0;
@@ -1456,10 +1456,10 @@ int     runrc                  = 0;


 uschar *search_error_message   = NULL;
 uschar *self_hostname          = NULL;
-uschar *sender_address         = NULL;
+const uschar *sender_address   = NULL;
 unsigned int sender_address_cache[(MAX_NAMED_LIST * 2)/32];
 uschar *sender_address_data    = NULL;
-uschar *sender_address_unrewritten = NULL;
+const uschar *sender_address_unrewritten = NULL;
 uschar *sender_data            = NULL;
 unsigned int sender_domain_cache[(MAX_NAMED_LIST * 2)/32];
 uschar *sender_fullhost        = NULL;
diff --git a/src/src/globals.h b/src/src/globals.h
index 9ec44487f..dff3762a8 100644
--- a/src/src/globals.h
+++ b/src/src/globals.h
@@ -350,8 +350,8 @@ extern uschar *acl_wherecodes[];       /* Response codes for ACL fails */
 extern uschar *acl_wherenames[];       /* Names for messages */
 extern address_item *addr_duplicate;   /* Duplicate address list */
 extern address_item address_defaults;  /* Default data for address item */
-extern uschar *address_file;           /* Name of file when delivering to one */
-extern uschar *address_pipe;           /* Pipe command when delivering to one */
+extern const uschar *address_file;           /* Name of file when delivering to one */
+extern const uschar *address_pipe;           /* Pipe command when delivering to one */
 extern tree_node *addresslist_anchor;  /* Tree of defined address lists */
 extern int     addresslist_count;      /* Number defined */
 extern gid_t  *admin_groups;           /* List of admin groups */
@@ -400,7 +400,7 @@ extern int     bsmtp_transaction_linecount; /* Start of last transaction */
 extern int     body_8bitmime;          /* sender declared BODY= ; 7=7BIT, 8=8BITMIME */
 extern uschar *bounce_message_file;    /* Template file */
 extern uschar *bounce_message_text;    /* One-liner */
-extern uschar *bounce_recipient;       /* When writing an errmsg */
+extern const uschar *bounce_recipient; /* When writing an errmsg */
 extern BOOL    bounce_return_body;     /* Include body in returned message */
 extern int     bounce_return_linesize_limit; /* Max line length in return */
 extern BOOL    bounce_return_message;  /* Include message in bounce */
@@ -517,14 +517,14 @@ extern const uschar *deliver_host_address; /* Address for remote delivery filter
 extern int     deliver_host_port;      /* Address for remote delivery filter */
 extern uschar *deliver_in_buffer;      /* Buffer for copying file */
 extern ino_t   deliver_inode;          /* Inode for appendfile */
-extern uschar *deliver_localpart;      /* The local part for delivery */
+extern const uschar *deliver_localpart;/* The local part for delivery */
 extern uschar *deliver_localpart_data; /* From local part lookup (de-tainted) */
-extern uschar *deliver_localpart_orig; /* The original local part for delivery */
-extern uschar *deliver_localpart_parent; /* The parent local part for delivery */
-extern uschar *deliver_localpart_prefix; /* The stripped prefix, if any */
-extern uschar *deliver_localpart_prefix_v; /* The stripped-prefix variable portion, if any */
-extern uschar *deliver_localpart_suffix; /* The stripped suffix, if any */
-extern uschar *deliver_localpart_suffix_v; /* The stripped-suffix variable portion, if any */
+extern const uschar *deliver_localpart_orig;        /* The original local part for delivery */
+extern const uschar *deliver_localpart_parent;        /* The parent local part for delivery */
+extern const uschar *deliver_localpart_prefix;        /* The stripped prefix, if any */
+extern const uschar *deliver_localpart_prefix_v;    /* The stripped-prefix variable portion, if any */
+extern const uschar *deliver_localpart_suffix;        /* The stripped suffix, if any */
+extern const uschar *deliver_localpart_suffix_v;    /* The stripped-suffix variable portion, if any */
 extern uschar *deliver_out_buffer;     /* Buffer for copying file */
 extern int     deliver_queue_load_max; /* Different value for queue running */
 extern address_item *deliver_recipients; /* Current set of addresses */
@@ -872,8 +872,8 @@ extern tree_node *ratelimiters_cmd;    /* Results of command ratelimit checks */
 extern tree_node *ratelimiters_conn;   /* Results of connection ratelimit checks */
 extern tree_node *ratelimiters_mail;   /* Results of per-mail ratelimit checks */
 extern uschar *raw_active_hostname;    /* Pre-expansion */
-extern uschar *raw_sender;             /* Before rewriting */
-extern uschar **raw_recipients;        /* Before rewriting */
+extern const uschar *raw_sender;       /* Before rewriting */
+extern const uschar **raw_recipients;  /* Before rewriting */
 extern int     raw_recipients_count;
 extern const uschar * rc_names[];      /* Mostly for debug output */
 extern int     rcpt_count;             /* Count of RCPT commands in a message */
@@ -885,7 +885,7 @@ extern int     receive_linecount;      /* Mainly for BSMTP errors */
 extern int     receive_messagecount;   /* Mainly for BSMTP errors */
 extern int     receive_timeout;        /* For non-SMTP acceptance */
 extern int     received_count;         /* Count of Received: headers */
-extern uschar *received_for;           /* For "for" field */
+extern const uschar *received_for;     /* For "for" field */
 extern uschar *received_header_text;   /* Definition of Received: header */
 extern int     received_headers_max;   /* Max count of Received: headers */
 extern struct timeval received_time;   /* Time the message started to be received */
@@ -926,7 +926,7 @@ extern retry_config *retries;          /* Chain of retry config information */
 extern int     retry_data_expire;      /* When to expire retry data */
 extern int     retry_interval_max;     /* Absolute maximum */
 extern int     retry_maximum_timeout;  /* The maximum timeout */
-extern uschar *return_path;            /* Return path for a message */
+extern const uschar *return_path;            /* Return path for a message */
 extern BOOL    return_path_remove;     /* Remove return-path headers */
 extern int     rewrite_existflags;     /* Indicate which headers have rewrites */
 extern uschar *rfc1413_hosts;          /* RFC hosts */
@@ -947,7 +947,7 @@ extern uschar *search_error_message;   /* Details of lookup problem */
 extern uschar *self_hostname;          /* Self host after routing->directors */
 extern unsigned int sender_address_cache[(MAX_NAMED_LIST * 2)/32]; /* Cache bits for sender */
 extern uschar *sender_address_data;    /* address_data from sender verify */
-extern uschar *sender_address_unrewritten; /* Set if rewritten by verify */
+extern const uschar *sender_address_unrewritten; /* Set if rewritten by verify */
 extern uschar *sender_data;            /* lookup result for senders */
 extern unsigned int sender_domain_cache[(MAX_NAMED_LIST * 2)/32]; /* Cache bits for sender domain */
 extern uschar *sender_fullhost;        /* Sender host name + address */
diff --git a/src/src/local_scan.h b/src/src/local_scan.h
index 153b4cb3c..ed9f26d62 100644
--- a/src/src/local_scan.h
+++ b/src/src/local_scan.h
@@ -153,9 +153,9 @@ field is always NULL except for one_time aliases that had errors_to on the
 routers that generated them. */


 typedef struct recipient_item {
-  uschar *address;              /* the recipient address */
+  const uschar *address;        /* the recipient address */
   int     pno;                  /* parent number for "one_time" alias, or -1 */
-  uschar *errors_to;            /* the errors_to address or NULL */
+  const uschar *errors_to;      /* the errors_to address or NULL */
   uschar *orcpt;                /* DSN orcpt */
   int     dsn_flags;            /* DSN flags */
 #ifdef EXPERIMENTAL_BRIGHTMAIL
@@ -181,7 +181,7 @@ extern uschar *message_id;             /* Internal id of message being handled *
 extern uschar *received_protocol;      /* Name of incoming protocol */
 extern int     recipients_count;       /* Number of recipients */
 extern recipient_item *recipients_list;/* List of recipient addresses */
-extern unsigned char *sender_address;  /* Sender address */
+extern const unsigned char *sender_address;    /* Sender address */
 extern uschar *sender_host_address;    /* IP address of sender, as chars */
 extern uschar *sender_host_authenticated; /* Name of authentication mechanism */
 extern uschar *sender_host_name;       /* Host name from lookup */
@@ -207,8 +207,8 @@ extern int     lss_match_domain(uschar *, uschar *);
 extern int     lss_match_local_part(uschar *, uschar *, BOOL);
 extern int     lss_match_address(uschar *, uschar *, BOOL);
 extern int     lss_match_host(uschar *, uschar *, uschar *);
-extern void    receive_add_recipient(uschar *, int);
-extern BOOL    receive_remove_recipient(uschar *);
+extern void    receive_add_recipient(const uschar *, int);
+extern BOOL    receive_remove_recipient(const uschar *);
 extern uschar *rfc2047_decode(uschar *, BOOL, const uschar *, int, int *,
                   uschar **);
 extern int     smtp_fflush(void);
diff --git a/src/src/log.c b/src/src/log.c
index af6e8b01b..f85823520 100644
--- a/src/src/log.c
+++ b/src/src/log.c
@@ -1032,11 +1032,10 @@ if (  flags & LOG_RECIPIENTS
    && g->ptr < LOG_BUFFER_SIZE - 6
    && raw_recipients_count > 0)
   {
-  int i;
   g = string_fmt_append_f(g, SVFMT_TAINT_NOCHK, " for", NULL);
-  for (i = 0; i < raw_recipients_count; i++)
+  for (int i = 0; i < raw_recipients_count; i++)
     {
-    uschar * s = raw_recipients[i];
+    const uschar * s = raw_recipients[i];
     if (LOG_BUFFER_SIZE - g->ptr < Ustrlen(s) + 3) break;
     g = string_fmt_append_f(g, SVFMT_TAINT_NOCHK, " %s", s);
     }
diff --git a/src/src/moan.c b/src/src/moan.c
index 25595816c..c2e38d4f7 100644
--- a/src/src/moan.c
+++ b/src/src/moan.c
@@ -158,8 +158,8 @@ Returns:         TRUE if message successfully sent
 */


 BOOL
-moan_send_message(uschar *recipient, int ident, error_block *eblock,
-  header_line *headers, FILE *message_file, uschar *firstline)
+moan_send_message(const uschar * recipient, int ident, error_block * eblock,
+  header_line * headers, FILE * message_file, uschar * firstline)
 {
 int written = 0;
 int fd;
@@ -631,7 +631,7 @@ if (addr)
   fprintf(f, "\nThe following address(es) have yet to be delivered:\n");
   for (; addr; addr = addr->next)
     {
-    uschar * parent = addr->parent ? addr->parent->address : NULL;
+    const uschar * parent = addr->parent ? addr->parent->address : NULL;
     fprintf(f, "  %s", addr->address);
     if (parent) fprintf(f, " <%s>", parent);
     if (addr->basic_errno > 0) fprintf(f, ": %s", strerror(addr->basic_errno));
@@ -734,22 +734,23 @@ Returns:    additional recipient list or NULL
 */


uschar *
-moan_check_errorcopy(uschar *recipient)
+moan_check_errorcopy(const uschar * recipient)
{
-uschar *item, *localpart, *domain;
-const uschar *listptr = errors_copy;
+uschar * item;
+const uschar * localpart, * domain;
+const uschar * listptr = errors_copy;
uschar *yield = NULL;
int sep = 0;
int llen;

-if (errors_copy == NULL) return NULL;
+if (!errors_copy) return NULL;

/* Set up pointer to the local part and domain, and compute the
length of the local part. */

 localpart = recipient;
 domain = Ustrrchr(recipient, '@');
-if (domain == NULL) return NULL;  /* should not occur, but avoid crash */
+if (!domain) return NULL;    /* should not occur, but avoid crash */
 llen = domain++ - recipient;


 /* Scan through the configured items */
diff --git a/src/src/queue.c b/src/src/queue.c
index cfe87e953..deedcde6f 100644
--- a/src/src/queue.c
+++ b/src/src/queue.c
@@ -585,7 +585,7 @@ for (int i = queue_run_in_order ? -1 : 0;
       else if (  deliver_selectstring_sender
           && !(f.deliver_selectstring_sender_regex
           ? regex_match(selectstring_regex_sender, sender_address, -1, NULL)
-          : (strstric(sender_address, deliver_selectstring_sender, FALSE)
+          : (strstric_c(sender_address, deliver_selectstring_sender, FALSE)
               != NULL)
           )   )
         {
@@ -601,10 +601,10 @@ for (int i = queue_run_in_order ? -1 : 0;
         int i;
         for (i = 0; i < recipients_count; i++)
           {
-          uschar *address = recipients_list[i].address;
+          const uschar * address = recipients_list[i].address;
           if (  (f.deliver_selectstring_regex
         ? regex_match(selectstring_regex, address, -1, NULL)
-                : (strstric(address, deliver_selectstring, FALSE) != NULL)
+                : (strstric_c(address, deliver_selectstring, FALSE) != NULL)
         )
              && tree_search(tree_nonrecipients, address) == NULL
          )
@@ -1369,9 +1369,10 @@ switch(action)
       tree_search(tree_nonrecipients, recipients_list[i].address);
     if (!delivered)
       {
-      uschar * save_local = deliver_localpart;
+      const uschar * save_local = deliver_localpart;
       const uschar * save_domain = deliver_domain;
-      uschar * addr = recipients_list[i].address, * errmsg = NULL;
+      const uschar * addr = recipients_list[i].address;
+      uschar * errmsg = NULL;
       int start, end, dom;


       if (!parse_extract_address(addr, &errmsg, &start, &end, &dom, TRUE))
diff --git a/src/src/rda.c b/src/src/rda.c
index 9c2aa5022..7d329c580 100644
--- a/src/src/rda.c
+++ b/src/src/rda.c
@@ -466,7 +466,7 @@ Returns:     FALSE if data missing
 */


static BOOL
-rda_read_string(int fd, uschar **sp)
+rda_read_string(int fd, uschar ** sp)
{
int len;

@@ -866,9 +866,9 @@ if (yield == FF_DELIVERED || yield == FF_NOTDELIVERED ||
   for (;;)
     {
     int i, reply_options;
-    address_item *addr;
-    uschar *recipient;
-    uschar *expandn[EXPAND_MAXN + 2];
+    address_item * addr;
+    uschar * recipient, * s;
+    uschar * expandn[EXPAND_MAXN + 2];


     /* First string is the address; NULL => end of addresses */


@@ -885,10 +885,11 @@ if (yield == FF_DELIVERED || yield == FF_NOTDELIVERED ||

     if (  read(fd, &addr->mode, sizeof(addr->mode)) != sizeof(addr->mode)
        || read(fd, &addr->flags, sizeof(addr->flags)) != sizeof(addr->flags)
-       || !rda_read_string(fd, &addr->prop.errors_address)
+       || !rda_read_string(fd, &s)
        || read(fd, &i, sizeof(i)) != sizeof(i)
        )
       goto DISASTER;
+    addr->prop.errors_address = s;
     addr->prop.ignore_error = (i != 0);


     /* Next comes a possible setting for $thisaddress and any numerical
diff --git a/src/src/receive.c b/src/src/receive.c
index 041898a6b..a459061ef 100644
--- a/src/src/receive.c
+++ b/src/src/receive.c
@@ -137,9 +137,9 @@ Returns:    TRUE for a trusted caller
 */


 BOOL
-receive_check_set_sender(uschar *newsender)
+receive_check_set_sender(const uschar * newsender)
 {
-uschar *qnewsender;
+const uschar * qnewsender;
 if (f.trusted_caller) return TRUE;
 if (!newsender || !untrusted_set_sender) return FALSE;
 qnewsender = Ustrchr(newsender, '@')
@@ -514,7 +514,7 @@ Returns:      nothing
 */


 void
-receive_add_recipient(uschar * recipient, int pno)
+receive_add_recipient(const uschar * recipient, int pno)
 {
 if (recipients_count >= recipients_list_max)
   {
@@ -591,7 +591,7 @@ Returns:      TRUE if it did remove something; FALSE otherwise
 */


 BOOL
-receive_remove_recipient(uschar *recipient)
+receive_remove_recipient(const uschar * recipient)
 {
 DEBUG(D_receive) debug_printf("receive_remove_recipient(\"%s\") called\n",
   recipient);
@@ -3600,7 +3600,7 @@ else
       /* Loop through recipients, responses must be in same order received */
       for (unsigned int c = 0; recipients_count > c; c++)
         {
-    uschar * addr= recipients_list[c].address;
+    const uschar * addr = recipients_list[c].address;
     uschar * msg= US"PRDR R=<%s> %s";
     uschar * code;
         DEBUG(D_receive)
diff --git a/src/src/rewrite.c b/src/src/rewrite.c
index ec5c2cffc..c0d173abf 100644
--- a/src/src/rewrite.c
+++ b/src/src/rewrite.c
@@ -119,9 +119,9 @@ for (rewrite_rule * rule = rewrite_rules;
   {
   int start, end, pdomain;
   int count = 0;
-  uschar *save_localpart;
-  const uschar *save_domain;
-  uschar *error, *new;
+  const uschar * save_localpart;
+  const uschar * save_domain;
+  uschar * error, * new;
   const uschar * newparsed;


   /* Come back here for a repeat after a successful rewrite. We do this
diff --git a/src/src/route.c b/src/src/route.c
index 82d51bc68..0bd87b837 100644
--- a/src/src/route.c
+++ b/src/src/route.c
@@ -859,12 +859,12 @@ Returns:       OK if all the tests succeed
 */


static BOOL
-check_router_conditions(router_instance *r, address_item *addr, int verify,
- struct passwd **pw, uschar **perror)
+check_router_conditions(router_instance * r, address_item * addr, int verify,
+ struct passwd ** pw, uschar ** perror)
{
int rc;
-uschar *check_local_part;
-unsigned int *localpart_cache;
+uschar * check_local_part;
+unsigned int * localpart_cache;

/* Reset variables to hold a home directory and data from lookup of a domain or
local part, and ensure search_find_defer is unset, in case there aren't any
@@ -928,15 +928,12 @@ because that doesn't have the prefix or suffix stripped. A bit of massaging is
required. Also, we only use the match cache for local parts that have not had
a prefix or suffix stripped. */

+check_local_part = string_copy(addr->cc_local_part);
 if (!addr->prefix && !addr->suffix)
-  {
   localpart_cache = addr->localpart_cache;
-  check_local_part = addr->cc_local_part;
-  }
 else
   {
   localpart_cache = NULL;
-  check_local_part = string_copy(addr->cc_local_part);
   if (addr->prefix)
     check_local_part += Ustrlen(addr->prefix);
   if (addr->suffix)
diff --git a/src/src/routers/accept.c b/src/src/routers/accept.c
index 63c8c22e4..8b72bfac1 100644
--- a/src/src/routers/accept.c
+++ b/src/src/routers/accept.c
@@ -104,9 +104,9 @@ accept_router_options_block *ob =
   (accept_router_options_block *)(rblock->options_block);
 */
 int rc;
-uschar *errors_to;
-uschar *remove_headers;
-header_line *extra_headers;
+const uschar * errors_to;
+uschar * remove_headers;
+header_line * extra_headers;


DEBUG(D_route) debug_printf("%s router called for %s\n domain = %s\n",
rblock->name, addr->address, addr->domain);
diff --git a/src/src/routers/redirect.c b/src/src/routers/redirect.c
index 6a17c2f8d..4c8e30563 100644
--- a/src/src/routers/redirect.c
+++ b/src/src/routers/redirect.c
@@ -306,9 +306,8 @@ redirect_router_options_block *ob =

while (generated)
{
- address_item *parent;
- address_item *next = generated;
- uschar *errors_address = next->prop.errors_address;
+ address_item * next = generated, * parent;
+ const uschar * errors_address = next->prop.errors_address;

   generated = next->next;
   next->parent = addr;
diff --git a/src/src/routers/rf_functions.h b/src/src/routers/rf_functions.h
index 91ccfb132..40d4cde1c 100644
--- a/src/src/routers/rf_functions.h
+++ b/src/src/routers/rf_functions.h
@@ -15,7 +15,7 @@ extern void rf_add_generated(router_instance *, address_item **,
 extern void rf_change_domain(address_item *, const uschar *, BOOL, address_item **);
 extern uschar *rf_expand_data(address_item *, uschar *, int *);
 extern int  rf_get_errors_address(address_item *, router_instance *,
-              int, uschar **);
+              int, const uschar **);
 extern int  rf_get_munge_headers(address_item *, router_instance *,
               header_line **, uschar **);
 extern BOOL rf_get_transport(uschar *, transport_instance **,  address_item *,
diff --git a/src/src/routers/rf_get_errors_address.c b/src/src/routers/rf_get_errors_address.c
index f70bdf25e..222d157d8 100644
--- a/src/src/routers/rf_get_errors_address.c
+++ b/src/src/routers/rf_get_errors_address.c
@@ -35,13 +35,13 @@ Returns:       OK if no problem
 */


int
-rf_get_errors_address(address_item *addr, router_instance *rblock,
- int verify, uschar **errors_to)
+rf_get_errors_address(address_item * addr, router_instance * rblock,
+ int verify, const uschar ** errors_to)
{
uschar *s;

*errors_to = addr->prop.errors_address;
-if (rblock->errors_to == NULL) return OK;
+if (!rblock->errors_to) return OK;

s = expand_string(rblock->errors_to);

@@ -84,17 +84,14 @@ if (verify != v_none)
else
{
BOOL save_address_test_mode = f.address_test_mode;
- int save1 = 0;
+ const uschar * save_sender = sender_address;
int i;
const uschar ***p;
const uschar *address_expansions_save[ADDRESS_EXPANSIONS_COUNT];
address_item *snew = deliver_make_addr(s, FALSE);

   if (sender_address)
-    {
-    save1 = sender_address[0];
-    sender_address[0] = 0;
-    }
+    sender_address = US"";


   for (i = 0, p = address_expansions; *p;)
     address_expansions_save[i++] = **p++;
@@ -124,7 +121,7 @@ else
   for (i = 0, p = address_expansions; *p; )
     **p++ = address_expansions_save[i++];


- if (sender_address) sender_address[0] = save1;
+ sender_address = save_sender;
}

return OK;
diff --git a/src/src/spf.c b/src/src/spf.c
index e72051708..2e3f861eb 100644
--- a/src/src/spf.c
+++ b/src/src/spf.c
@@ -341,7 +341,8 @@ else for (int i = 0; i < SPF_response_messages(spf_response); i++)
Return: OK/FAIL */

int
-spf_process(const uschar **listptr, uschar *spf_envelope_sender, int action)
+spf_process(const uschar ** listptr, const uschar * spf_envelope_sender,
+ int action)
{
int sep = 0;
const uschar *list = *listptr;
diff --git a/src/src/spf.h b/src/src/spf.h
index 76c7522bd..afee742ed 100644
--- a/src/src/spf.h
+++ b/src/src/spf.h
@@ -29,7 +29,7 @@ typedef struct spf_result_id {
gstring * spf_lib_version_report(gstring *);
BOOL spf_init(void);
BOOL spf_conn_init(uschar *, uschar *);
-int spf_process(const uschar **, uschar *, int);
+int spf_process(const uschar **, const uschar *, int);
void spf_response_debug(SPF_response_t *);

#define SPF_PROCESS_NORMAL 0
diff --git a/src/src/spool_in.c b/src/src/spool_in.c
index 588effd2c..3e3b246ab 100644
--- a/src/src/spool_in.c
+++ b/src/src/spool_in.c
@@ -456,9 +456,12 @@ n = Ustrlen(big_buffer);
if (n < 3 || big_buffer[0] != '<' || big_buffer[n-2] != '>')
goto SPOOL_FORMAT_ERROR;

-sender_address = store_get(n-2, GET_TAINTED);
-Ustrncpy(sender_address, big_buffer+1, n-3);
-sender_address[n-3] = 0;
+ {
+ uschar * s = store_get(n-2, GET_TAINTED);
+ Ustrncpy(s, big_buffer+1, n-3);
+ s[n-3] = '\0';
+ sender_address = s;
+ }

 where = US"time";
 if (Ufgets(big_buffer, big_buffer_size, fp) == NULL) goto SPOOL_READ_ERROR;
diff --git a/src/src/structs.h b/src/src/structs.h
index 214819482..209d657c6 100644
--- a/src/src/structs.h
+++ b/src/src/structs.h
@@ -526,7 +526,7 @@ typedef struct address_item_propagated {
   uschar *address_data;           /* arbitrary data to keep with the address */
   uschar *domain_data;            /* from "domains" lookup */
   uschar *localpart_data;         /* from "local_parts" lookup */
-  uschar *errors_address;         /* where to send errors (NULL => sender) */
+  const uschar *errors_address;         /* where to send errors (NULL => sender) */
   header_line *extra_headers;     /* additional headers */
   uschar *remove_headers;         /* list of those to remove */
   void   *variables;          /* router-vasriables */
@@ -561,15 +561,15 @@ typedef struct address_item {
   reply_item *reply;              /* data for autoreply */
   retry_item *retries;            /* chain of retry information */


-  uschar *address;                /* address being delivered or routed */
+  const uschar *address;                /* address being delivered or routed */
   uschar *unique;                 /* used for disambiguating */
-  uschar *cc_local_part;          /* caseful local part */
-  uschar *lc_local_part;          /* lowercased local part */
-  uschar *local_part;             /* points to cc or lc version */
-  uschar *prefix;                 /* stripped prefix of local part */
-  uschar *prefix_v;          /*  variable part of above */
-  uschar *suffix;                 /* stripped suffix of local part */
-  uschar *suffix_v;          /*  variable part of above */
+  const uschar *cc_local_part;    /* caseful local part */
+  const uschar *lc_local_part;    /* lowercased local part */
+  const uschar *local_part;       /* points to cc or lc version */
+  const uschar *prefix;           /* stripped prefix of local part */
+  const uschar *prefix_v;      /*  variable part of above */
+  const uschar *suffix;           /* stripped suffix of local part */
+  const uschar *suffix_v;      /*  variable part of above */
   const uschar *domain;           /* working domain (lower cased) */


   uschar *address_retry_key;      /* retry key including full address */
@@ -580,7 +580,7 @@ typedef struct address_item {
   uschar *message;                /* error message */
   uschar *user_message;           /* error message that can be sent over SMTP
                                      or quoted in bounce message */
-  uschar *onetime_parent;         /* saved original parent for onetime */
+  const uschar *onetime_parent;         /* saved original parent for onetime */
   uschar **pipe_expandn;          /* numeric expansions for pipe from filter */
   uschar *return_filename;        /* name of return file */
   uschar *self_hostname;          /* after self=pass */
diff --git a/src/src/transport.c b/src/src/transport.c
index b3b05c0a3..a0f097579 100644
--- a/src/src/transport.c
+++ b/src/src/transport.c
@@ -434,10 +434,10 @@ Returns:     TRUE on success, FALSE on failure (with errno preserved)
 */


BOOL
-write_chunk(transport_ctx * tctx, uschar *chunk, int len)
+write_chunk(transport_ctx * tctx, const uschar * chunk, int len)
{
-uschar *start = chunk;
-uschar *end = chunk + len;
+const uschar * start = chunk;
+const uschar * end = chunk + len;
int mlen = DELIVER_OUT_BUFFER_SIZE - nl_escape_length - 2;

/* The assumption is made that the check string will never stretch over move
@@ -474,7 +474,7 @@ if (nl_partial_match >= 0)
for possible escaping. The code for the non-NL route should be as fast as
possible. */

-for (uschar * ptr = start; ptr < end; ptr++)
+for (const uschar * ptr = start; ptr < end; ptr++)
{
int ch, len;

@@ -580,7 +580,7 @@ Arguments:
 Returns:            a string
 */


-uschar *
+const uschar *
 transport_rcpt_address(address_item *addr, BOOL include_affixes)
 {
 uschar *at;
@@ -704,7 +704,7 @@ Returns:                TRUE on success; FALSE on failure.
 */
 BOOL
 transport_headers_send(transport_ctx * tctx,
-  BOOL (*sendfn)(transport_ctx * tctx, uschar * s, int len))
+  BOOL (*sendfn)(transport_ctx * tctx, const uschar * s, int len))
 {
 const uschar * list;
 transport_instance * tblock = tctx ? tctx->tblock : NULL;
@@ -2302,7 +2302,7 @@ if (flags & TSUC_EXPAND_ARGS)
       address_pipe_argv = store_get((address_pipe_max_args+1)*sizeof(uschar *), GET_UNTAINTED);


       /* +1 because addr->local_part[0] == '|' since af_force_command is set */
-      s = expand_string(addr->local_part + 1);
+      s = expand_cstring(addr->local_part + 1);


       if (!s || !*s)
         {
diff --git a/src/src/transports/appendfile.c b/src/src/transports/appendfile.c
index 2c7bea11d..ec41ca035 100644
--- a/src/src/transports/appendfile.c
+++ b/src/src/transports/appendfile.c
@@ -502,7 +502,7 @@ Returns:     nothing
 */


 static void
-notify_comsat(uschar *user, off_t offset)
+notify_comsat(const uschar * user, off_t offset)
 {
 struct servent *sp;
 host_item host;
diff --git a/src/src/transports/pipe.c b/src/src/transports/pipe.c
index b9cc32df1..64c70e719 100644
--- a/src/src/transports/pipe.c
+++ b/src/src/transports/pipe.c
@@ -292,7 +292,7 @@ Returns:             TRUE if all went well; otherwise an error will be
 */


 static BOOL
-set_up_direct_command(const uschar *** argvptr, uschar * cmd,
+set_up_direct_command(const uschar *** argvptr, const uschar * cmd,
   BOOL expand_arguments, int expand_fail, address_item * addr, uschar * tname,
   pipe_transport_options_block * ob)
 {
@@ -414,8 +414,8 @@ Returns:             TRUE if all went well; otherwise an error will be
 */


static BOOL
-set_up_shell_command(const uschar ***argvptr, uschar *cmd,
- BOOL expand_arguments, int expand_fail, address_item *addr, uschar *tname)
+set_up_shell_command(const uschar *** argvptr, const uschar * cmd,
+ BOOL expand_arguments, int expand_fail, address_item * addr, uschar * tname)
{
const uschar **argv;

@@ -462,10 +462,10 @@ if (expand_arguments)
       }


     g = string_cat(g, q);
-    argv[2] = (cmd = string_from_gstring(g)) ? expand_string(cmd) : NULL;
+    argv[2] = (cmd = string_from_gstring(g)) ? expand_cstring(cmd) : NULL;
     }
   else
-    argv[2] = expand_string(cmd);
+    argv[2] = expand_cstring(cmd);


f.enable_dollar_recipients = FALSE;

@@ -518,11 +518,12 @@ pipe_transport_options_block *ob =
int timeout = ob->timeout;
BOOL written_ok = FALSE;
BOOL expand_arguments;
-const uschar **argv;
-uschar *envp[50];
-const uschar *envlist = ob->environment;
-uschar *cmd, *ss;
-uschar *eol = ob->use_crlf ? US"\r\n" : US"\n";
+const uschar ** argv;
+uschar * envp[50];
+const uschar * envlist = ob->environment;
+const uschar * cmd;
+uschar * ss;
+uschar * eol = ob->use_crlf ? US"\r\n" : US"\n";
transport_ctx tctx = {
.tblock = tblock,
.addr = addr,
diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c
index 8c00a1ef2..c53e1000f 100644
--- a/src/src/transports/smtp.c
+++ b/src/src/transports/smtp.c
@@ -656,8 +656,7 @@ static void
deferred_event_raise(address_item * addr, host_item * host, uschar * evstr)
{
uschar * action = addr->transport->event_action;
-const uschar * save_domain;
-uschar * save_local;
+const uschar * save_domain, * save_local;

if (!action)
return;
@@ -1793,7 +1792,7 @@ return FALSE;

 typedef struct smtp_compare_s
 {
-    uschar *            current_sender_address;
+    const uschar *        current_sender_address;
     struct transport_instance *    tblock;
 } smtp_compare_t;


@@ -1803,7 +1802,7 @@ sender_address, helo_data and tls_certificate if enabled.
*/

static uschar *
-smtp_local_identity(uschar * sender, struct transport_instance * tblock)
+smtp_local_identity(const uschar * sender, struct transport_instance * tblock)
{
address_item * addr1;
uschar * if1 = US"";
@@ -1811,7 +1810,7 @@ uschar * helo1 = US"";
#ifndef DISABLE_TLS
uschar * tlsc1 = US"";
#endif
-uschar * save_sender_address = sender_address;
+const uschar * save_sender_address = sender_address;
uschar * local_identity = NULL;
smtp_transport_options_block * ob = SOB tblock->options_block;

@@ -3434,7 +3433,7 @@ buffer. */
 sx->pending_MAIL = TRUE;     /* The block starts with MAIL */


{
- uschar * s = sx->from_addr;
+ const uschar * s = sx->from_addr;
#ifdef SUPPORT_I18N
uschar * errstr = NULL;

@@ -3505,7 +3504,7 @@ for (addr = sx->first_addr, address_count = 0, pipe_limit = 100;
{
int cmds_sent;
BOOL no_flush;
- uschar * rcpt_addr;
+ const uschar * rcpt_addr;

 #ifdef EXPERIMENTAL_ESMTP_LIMITS
   if (  sx->single_rcpt_domain                    /* restriction on domains */
diff --git a/src/src/transports/smtp.h b/src/src/transports/smtp.h
index 0d15b9626..1f888ee0b 100644
--- a/src/src/transports/smtp.h
+++ b/src/src/transports/smtp.h
@@ -140,7 +140,7 @@ typedef struct {


 /* smtp connect context */
 typedef struct {
-  uschar *        from_addr;
+  const uschar *    from_addr;
   address_item *    addrlist;


   smtp_connect_args    conn_args;
diff --git a/src/src/verify.c b/src/src/verify.c
index 6361aa434..bc3666285 100644
--- a/src/src/verify.c
+++ b/src/src/verify.c
@@ -105,8 +105,8 @@ Return: TRUE if result found
 */


static BOOL
-cached_callout_lookup(address_item * addr, uschar * address_key,
- uschar * from_address, int * opt_ptr, uschar ** pm_ptr,
+cached_callout_lookup(address_item * addr, const uschar * address_key,
+ const uschar * from_address, int * opt_ptr, uschar ** pm_ptr,
int * yield, uschar ** failure_ptr,
dbdata_callout_cache * new_domain_record, int * old_domain_res)
{
@@ -278,10 +278,10 @@ return FALSE;
*/
static void
cache_callout_write(dbdata_callout_cache * dom_rec, const uschar * domain,
- int done, dbdata_callout_cache_address * addr_rec, uschar * address_key)
+ int done, dbdata_callout_cache_address * addr_rec, const uschar * address_key)
{
open_db dbblock;
-open_db *dbm_file = NULL;
+open_db * dbm_file = NULL;

/* If we get here with done == TRUE, a successful callout happened, and yield
will be set OK or FAIL according to the response to the RCPT command.
@@ -502,11 +502,11 @@ do_callout(address_item *addr, host_item *host_list, transport_feedback *tf,
int yield = OK;
int old_domain_cache_result = ccache_accept;
BOOL done = FALSE;
-uschar *address_key;
-uschar *from_address;
-uschar *random_local_part = NULL;
-const uschar *save_deliver_domain = deliver_domain;
-uschar **failure_ptr = options & vopt_is_recipient
+const uschar * address_key;
+const uschar * from_address;
+uschar * random_local_part = NULL;
+const uschar * save_deliver_domain = deliver_domain;
+uschar ** failure_ptr = options & vopt_is_recipient
? &recipient_verify_failure : &sender_verify_failure;
dbdata_callout_cache new_domain_record;
dbdata_callout_cache_address new_address_record;
@@ -771,7 +771,7 @@ tls_retry_connection:

     if (random_local_part)
       {
-      uschar * main_address = addr->address;
+      const uschar * main_address = addr->address;
       const uschar * rcpt_domain = addr->domain;


#ifdef SUPPORT_I18N
@@ -942,7 +942,7 @@ tls_retry_connection:

       if (done)
     {
-    uschar * main_address = addr->address;
+    const uschar * main_address = addr->address;


     /*XXX oops, affixes */
     addr->address = string_sprintf("postmaster@%.1000s", addr->domain);
@@ -1286,7 +1286,7 @@ return FALSE;



static BOOL
-_cutthrough_puts(uschar * cp, int n)
+_cutthrough_puts(const uschar * cp, int n)
{
while(n--)
{
@@ -1301,7 +1301,7 @@ return TRUE;

/* Buffered output of counted data block. Return boolean success */
static BOOL
-cutthrough_puts(uschar * cp, int n)
+cutthrough_puts(const uschar * cp, int n)
{
if (cutthrough.cctx.sock < 0) return TRUE;
if (_cutthrough_puts(cp, n)) return TRUE;
@@ -1407,9 +1407,9 @@ return cutthrough_response(&cutthrough.cctx, '3', NULL, CUTTHROUGH_DATA_TIMEOUT)

 /* tctx arg only to match write_chunk() */
 static BOOL
-cutthrough_write_chunk(transport_ctx * tctx, uschar * s, int len)
+cutthrough_write_chunk(transport_ctx * tctx, const uschar * s, int len)
 {
-uschar * s2;
+const uschar * s2;
 while(s && (s2 = Ustrchr(s, '\n')))
  {
  if(!cutthrough_puts(s, s2-s) || !cutthrough_put_nl())
@@ -1697,16 +1697,16 @@ int yield = OK;
 int verify_type = expn ? v_expn :
    f.address_test_mode ? v_none :
           options & vopt_is_recipient ? v_recipient : v_sender;
-address_item *addr_list;
-address_item *addr_new = NULL;
-address_item *addr_remote = NULL;
-address_item *addr_local = NULL;
-address_item *addr_succeed = NULL;
-uschar **failure_ptr = options & vopt_is_recipient
+address_item * addr_list;
+address_item * addr_new = NULL;
+address_item * addr_remote = NULL;
+address_item * addr_local = NULL;
+address_item * addr_succeed = NULL;
+uschar ** failure_ptr = options & vopt_is_recipient
   ? &recipient_verify_failure : &sender_verify_failure;
-uschar *ko_prefix, *cr;
-uschar *address = vaddr->address;
-uschar *save_sender;
+uschar * ko_prefix, * cr;
+const uschar * address = vaddr->address;
+const uschar * save_sender;
 uschar null_sender[] = { 0 };             /* Ensure writeable memory */


/* Clear, just in case */
@@ -1751,9 +1751,8 @@ may have been set by domains and local part tests during an ACL. */

 if (global_rewrite_rules)
   {
-  uschar *old = address;
-  /* deconst ok as address was not const */
-  address = US rewrite_address(address, options & vopt_is_recipient, FALSE,
+  const uschar * old = address;
+  address = rewrite_address(address, options & vopt_is_recipient, FALSE,
     global_rewrite_rules, rewrite_existflags);
   if (address != old)
     {
@@ -1919,8 +1918,8 @@ while (addr_new)
       if (tf.hosts && (!host_list || tf.hosts_override))
         {
         uschar *s;
-        const uschar *save_deliver_domain = deliver_domain;
-        uschar *save_deliver_localpart = deliver_localpart;
+        const uschar * save_deliver_domain = deliver_domain;
+        const uschar * save_deliver_localpart = deliver_localpart;


         host_list = NULL;    /* Ignore the router's hosts */


@@ -2455,11 +2454,11 @@ verify_check_notblind(BOOL case_sensitive)
for (int i = 0; i < recipients_count; i++)
{
BOOL found = FALSE;
- uschar *address = recipients_list[i].address;
+ const uschar * address = recipients_list[i].address;

   for (header_line * h = header_list; !found && h; h = h->next)
     {
-    uschar *colon, *s;
+    uschar * colon, * s;


     if (h->type != htype_to && h->type != htype_cc) continue;


@@ -2533,7 +2532,7 @@ Returns:     pointer to an address item, or NULL
 */


address_item *
-verify_checked_sender(uschar *sender)
+verify_checked_sender(const uschar * sender)
{
for (address_item * addr = sender_verified_list; addr; addr = addr->next)
if (Ustrcmp(sender, addr->address) == 0) return addr;

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-cvs.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-cvs-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/