Fix $regex<n> use-after-free. Bug 2915
[exim.git] / src / src / exim.c
index 99a4faa8c91cbcf9dec0aeb9674e2094b9d1f5e0..b9328f017decb15734c935995cda28a66dfbbe32 100644 (file)
@@ -232,7 +232,7 @@ exit(1);
 ***********************************************/
 
 #define STACKDUMP_MAX 24
-static void
+void
 stackdump(void)
 {
 #ifndef NO_EXECINFO
@@ -1670,6 +1670,8 @@ if (isupper(big_buffer[0]))
   if (macro_read_assignment(big_buffer))
     printf("Defined macro '%s'\n", mlast->name);
   }
+else if (Ustrncmp(big_buffer, "set ", 4) == 0)
+  printf("%s\n", acl_standalone_setvar(big_buffer+4));
 else
   if ((s = expand_string(big_buffer))) printf("%s\n", CS s);
   else printf("Failed: %s\n", expand_string_message);
@@ -1998,8 +2000,6 @@ regex_whitelisted_macro =
   regex_must_compile(US"^[A-Za-z0-9_/.-]*$", MCS_NOFLAGS, TRUE);
 #endif
 
-for (i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL;
-
 /* If the program is called as "mailq" treat it as equivalent to "exim -bp";
 this seems to be a generally accepted convention, since one finds symbolic
 links called "mailq" in standard OS configurations. */
@@ -4062,7 +4062,7 @@ defined) */
   {
   int old_pool = store_pool;
 #ifdef MEASURE_TIMING
-  struct timeval t0, diff;
+  struct timeval t0;
   (void)gettimeofday(&t0, NULL);
 #endif
 
@@ -4694,7 +4694,7 @@ needed in transports so we lost the optimisation. */
   {
   int old_pool = store_pool;
 #ifdef MEASURE_TIMING
-  struct timeval t0, diff;
+  struct timeval t0;
   (void)gettimeofday(&t0, NULL);
 #endif
 
@@ -5088,7 +5088,7 @@ if (f.daemon_listen || f.inetd_wait_mode || queue_interval > 0)
   routines in it, so call even if tls_require_ciphers is unset */
     {
 # ifdef MEASURE_TIMING
-    struct timeval t0, diff;
+    struct timeval t0;
     (void)gettimeofday(&t0, NULL);
 # endif
     if (!tls_dropprivs_validate_require_cipher(FALSE))
@@ -6087,7 +6087,7 @@ MORELOOP:
   deliver_localpart_data = deliver_domain_data =
   recipient_data = sender_data = NULL;
   acl_var_m = NULL;
-  for(int i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL;
+  regex_vars_clear();
 
   store_reset(reset_point);
   }