something non-NULL if exists_only is TRUE
*/
-static uschar *
+static const uschar *
find_variable(uschar *name, BOOL exists_only, BOOL skipping, int *newsize)
{
var_entry * vp;
{
uschar *endptr;
int n = Ustrtoul(name + 4, &endptr, 10);
- if (*endptr == 0 && n != 0 && n <= AUTH_VARS)
- return !auth_vars[n-1] ? US"" : auth_vars[n-1];
+ if (!*endptr && n != 0 && n <= AUTH_VARS)
+ return auth_vars[n-1] ? auth_vars[n-1] : US"";
}
else if (Ustrncmp(name, "regex", 5) == 0)
{
uschar *endptr;
int n = Ustrtoul(name + 5, &endptr, 10);
- if (*endptr == 0 && n != 0 && n <= REGEX_VARS)
- return !regex_vars[n-1] ? US"" : regex_vars[n-1];
+ if (!*endptr && n != 0 && n <= REGEX_VARS)
+ return regex_vars[n-1] ? regex_vars[n-1] : US"";
}
/* For all other variables, search the table */
case ECOND_DEF:
{
- uschar * t;
+ const uschar * t;
if (*s != ':')
{
*/
static int
-save_expand_strings(uschar **save_expand_nstring, int *save_expand_nlength)
+save_expand_strings(const uschar **save_expand_nstring, int *save_expand_nlength)
{
for (int i = 0; i <= expand_nmax; i++)
{
*/
static void
-restore_expand_strings(int save_expand_nmax, uschar **save_expand_nstring,
+restore_expand_strings(int save_expand_nmax, const uschar **save_expand_nstring,
int *save_expand_nlength)
{
expand_nmax = save_expand_nmax;
gstring * yield = string_get(Ustrlen(string) + 64);
int item_type;
const uschar *s = string;
-uschar *save_expand_nstring[EXPAND_MAXN+1];
+const uschar *save_expand_nstring[EXPAND_MAXN+1];
int save_expand_nlength[EXPAND_MAXN+1];
BOOL resetok = TRUE;
while (*s)
{
- uschar *value;
uschar name[256];
/* \ escapes the next character, which must exist, or else
if (isalpha((*(++s))))
{
+ const uschar * value;
int len;
int newsize = 0;
gstring * g = NULL;
But there is no error here - nothing gets inserted. */
if (!value)
- {
+ { /*{*/
if (Ustrchr(name, '}')) malformed_header = TRUE;
continue;
}
yield = g;
yield->size = newsize;
yield->ptr = len;
- yield->s = value;
+ yield->s = US value; /* known to be in new store i.e. a copy, so deconst safe */
}
else
yield = string_catn(yield, value, len);
/*{*/
if (*s++ == '}')
{
+ const uschar * value;
int len;
int newsize = 0;
gstring * g = NULL;
yield = g;
yield->size = newsize;
yield->ptr = len;
- yield->s = value;
+ yield->s = US value; /* known to be in new store i.e. a copy, so deconst safe */
}
else
yield = string_catn(yield, value, len);
const uschar *var_data;
} err_ctx;
+/* Called via tree_walk, which allows nonconst name/data. Our usage is const. */
static void
assert_variable_notin(uschar * var_name, uschar * var_data, void * ctx)
{
tree_walk(acl_var_c, assert_variable_notin, &e);
tree_walk(acl_var_m, assert_variable_notin, &e);
-/* check auth<n> variables */
+/* check auth<n> variables.
+assert_variable_notin() treats as const, so deconst is safe. */
for (int i = 0; i < AUTH_VARS; i++) if (auth_vars[i])
- assert_variable_notin(US"auth<n>", auth_vars[i], &e);
+ assert_variable_notin(US"auth<n>", US auth_vars[i], &e);
-/* check regex<n> variables */
+/* check regex<n> variables. assert_variable_notin() treats as const. */
for (int i = 0; i < REGEX_VARS; i++) if (regex_vars[i])
- assert_variable_notin(US"regex<n>", regex_vars[i], &e);
+ assert_variable_notin(US"regex<n>", US regex_vars[i], &e);
/* check known-name variables */
for (var_entry * v = var_table; v < var_table + var_table_size; v++)
uschar *auth_defer_msg = US"reason not recorded";
uschar *auth_defer_user_msg = US"";
-uschar *auth_vars[AUTH_VARS];
+const uschar *auth_vars[AUTH_VARS];
int auto_thaw = 0;
#ifdef WITH_CONTENT_SCAN
int av_failed = FALSE; /* boolean but accessed as vtype_int*/
int expand_forbid = 0;
int expand_nlength[EXPAND_MAXN+1];
int expand_nmax = -1;
-uschar *expand_nstring[EXPAND_MAXN+1];
+const uschar *expand_nstring[EXPAND_MAXN+1];
uschar *expand_string_message;
uschar *extra_local_interfaces = NULL;
#endif
const pcre2_code *regex_ismsgid = NULL;
const pcre2_code *regex_smtp_code = NULL;
-uschar *regex_vars[REGEX_VARS];
+const uschar *regex_vars[REGEX_VARS];
#ifdef WHITELIST_D_MACROS
const pcre2_code *regex_whitelisted_macro = NULL;
#endif
extern auth_instance auth_defaults; /* Default values */
extern uschar *auth_defer_msg; /* Error message for log */
extern uschar *auth_defer_user_msg; /* Error message for user */
-extern uschar *auth_vars[]; /* $authn variables */
+extern const uschar *auth_vars[]; /* $authn variables */
extern int auto_thaw; /* Auto-thaw interval */
#ifdef WITH_CONTENT_SCAN
extern int av_failed; /* TRUE if the AV process failed */
extern int expand_forbid; /* RDO flags for forbidding things */
extern int expand_nlength[]; /* Lengths of numbered strings */
extern int expand_nmax; /* Max numerical value */
-extern uschar *expand_nstring[]; /* Numbered strings */
+extern const uschar *expand_nstring[]; /* Numbered strings */
extern BOOL extract_addresses_remove_arguments; /* Controls -t behaviour */
extern uschar *extra_local_interfaces; /* Local, non-listen interfaces */
#ifndef DISABLE_PIPE_CONNECT
extern const pcre2_code *regex_EARLY_PIPE; /* For recognizing PIPE_CONNCT */
#endif
-extern const pcre2_code *regex_ismsgid; /* Compiled r.e. for message it */
+extern const pcre2_code *regex_ismsgid; /* Compiled r.e. for message ID */
extern const pcre2_code *regex_smtp_code; /* For recognizing SMTP codes */
-extern uschar *regex_vars[]; /* $regexN variables */
+extern const uschar *regex_vars[]; /* $regexN variables */
#ifdef WHITELIST_D_MACROS
extern const pcre2_code *regex_whitelisted_macro; /* For -D macro values */
#endif