JH/02 Move from using the pcre library to pcre2. The former is no longer
being developed or supported (by the original developer).
+JH/03 Constification work in the filters module required a major version
+ bump for the local-scan API. Specifically, the "headers_charset"
+ global which is visible via the API is now const and may therefore
+ not be modified by local-scan code.
+
Exim version 4.95
-----------------
*/
static uschar *
-find_header(uschar *name, int *newsize, unsigned flags, uschar *charset)
+find_header(uschar *name, int *newsize, unsigned flags, const uschar *charset)
{
BOOL found = !name;
int len = name ? Ustrlen(name) : 0;
unsigned flags = *name == 'r' ? FH_WANT_RAW
: *name == 'l' ? FH_WANT_RAW|FH_WANT_LIST
: 0;
- uschar * charset = *name == 'b' ? NULL : headers_charset;
+ const uschar * charset = *name == 'b' ? NULL : headers_charset;
s = read_header_name(name, sizeof(name), s);
value = find_header(name, &newsize, flags, charset);
s = expargs[0];
if (filter_test != FTEST_NONE)
- printf("Headers %s \"%s\"\n", (subtype == TRUE)? "add" :
- (subtype == FALSE)? "remove" : "charset", string_printing(s));
+ printf("Headers %s \"%s\"\n",
+ subtype == TRUE ? "add"
+ : subtype == FALSE ? "remove"
+ : "charset",
+ string_printing(s));
if (subtype == TRUE)
{
while (isspace(*s)) s++;
- if (s[0] != 0)
+ if (*s)
{
- header_add(htype_other, "%s%s", s, (s[Ustrlen(s)-1] == '\n')?
- "" : "\n");
+ header_add(htype_other, "%s%s", s,
+ s[Ustrlen(s)-1] == '\n' ? "" : "\n");
header_last->type = header_checkname(header_last, FALSE);
if (header_last->type >= 'a') header_last->type = htype_other;
}
/* This setting lasts only while the filter is running; on exit, the
variable is reset to the previous value. */
- else headers_charset = s; /*XXX loses track of const */
+ else headers_charset = s;
}
break;
ff_name = US"freeze";
ff_ret = FF_FREEZE;
- DEFERFREEZEFAIL:
- fmsg = expargs[0]; /*XXX loses track of const */
- if (Ustrlen(fmsg) > 1024) Ustrcpy(fmsg + 1000, US" ... (truncated)");
- fmsg = US string_printing(fmsg);
- *error_pointer = fmsg;
+ DEFERFREEZEFAIL:
+ *error_pointer = fmsg = US string_printing(Ustrlen(expargs[0]) > 1024
+ ? string_sprintf("%.1000s ... (truncated)", expargs[0])
+ : string_copy(expargs[0]));
if (filter_test != FTEST_NONE)
{
indent();
printf("%c%s text \"%s\"\n", toupper(ff_name[0]), ff_name+1, fmsg);
}
- else DEBUG(D_filter) debug_printf_indent("Filter: %s \"%s\"\n", ff_name, fmsg);
+ else
+ DEBUG(D_filter) debug_printf_indent("Filter: %s \"%s\"\n", ff_name, fmsg);
return ff_ret;
case finish_command:
printf("%sinish\n", (commands->seen)? "Seen f" : "F");
}
else
- {
DEBUG(D_filter) debug_printf_indent("Filter: %sfinish\n",
- (commands->seen)? " Seen " : "");
- }
+ commands->seen ? " Seen " : "");
finish_obeyed = TRUE;
- return filter_delivered? FF_DELIVERED : FF_NOTDELIVERED;
+ return filter_delivered ? FF_DELIVERED : FF_NOTDELIVERED;
case if_command:
{
uschar *save_address = filter_thisaddress;
int ok = FF_DELIVERED;
condition_value = test_condition(commands->args[0].c, TRUE);
- if (*error_pointer != NULL) ok = FF_ERROR; else
+ if (*error_pointer)
+ ok = FF_ERROR;
+ else
{
output_indent += 2;
ok = interpret_commands(commands->args[condition_value? 1:2].f,
output_indent -= 2;
}
filter_thisaddress = save_address;
- if (finish_obeyed || (ok != FF_DELIVERED && ok != FF_NOTDELIVERED))
+ if (finish_obeyed || ok != FF_DELIVERED && ok != FF_NOTDELIVERED)
return ok;
}
break;
case mail_command:
case vacation_command:
- if (return_path == NULL || return_path[0] == 0)
+ if (!return_path || !*return_path)
{
if (filter_test != FTEST_NONE)
printf("%s command ignored because return_path is empty\n",
for (i = 0; i < MAILARGS_STRING_COUNT; i++)
{
- uschar *p;
+ const uschar *p;
const uschar *s = expargs[i];
- if (s == NULL) continue;
+ if (!s) continue;
if (i != mailarg_index_text) for (p = s; *p != 0; p++)
{
else
{
- uschar *pp;
+ const uschar *pp;
for (pp = p + 1;; pp++)
{
c = *pp;
if (c == ':' && pp != p + 1) break;
- if (c == 0 || c == ':' || isspace(*pp))
+ if (!c || c == ':' || isspace(c))
{
*error_pointer = string_sprintf("\\n not followed by space or "
"valid header name in \"%.1024s\" in %s command",
commands->noerror ? " (noerror)" : "");
for (i = 1; i < MAILARGS_STRING_COUNT; i++)
{
- uschar *arg = commands->args[i].u;
+ const uschar *arg = commands->args[i].u;
if (arg)
{
int len = Ustrlen(mailargs[i]);
int i;
int yield = FF_ERROR;
uschar *ptr = filter;
-uschar *save_headers_charset = headers_charset;
+const uschar *save_headers_charset = headers_charset;
filter_cmd *commands = NULL;
filter_cmd **lastcmdptr = &commands;
extern const uschar *parse_find_at(const uschar *);
extern const uschar *parse_fix_phrase(const uschar *, int);
extern const uschar *parse_message_id(const uschar *, uschar **, uschar **);
-extern const uschar *parse_quote_2047(const uschar *, int, uschar *, BOOL);
+extern const uschar *parse_quote_2047(const uschar *, int, const uschar *,
+ BOOL);
extern const uschar *parse_date_time(const uschar *str, time_t *t);
extern void priv_drop_temp(const uid_t, const gid_t);
extern void priv_restore(void);
extern const uschar *rewrite_one(const uschar *, int, BOOL *, BOOL, uschar *,
rewrite_rule *);
extern void rewrite_test(const uschar *);
-extern uschar *rfc2047_decode2(uschar *, BOOL, uschar *, int, int *, int *,
- uschar **);
+extern uschar *rfc2047_decode2(uschar *, BOOL, const uschar *, int, int *,
+ int *, uschar **);
extern int route_address(address_item *, address_item **, address_item **,
address_item **, address_item **, int);
extern int route_check_prefix(const uschar *, const uschar *, unsigned *);
volatile sig_atomic_t had_command_sigterm = 0;
volatile sig_atomic_t had_data_timeout = 0;
volatile sig_atomic_t had_data_sigint = 0;
-uschar *headers_charset = US HEADERS_CHARSET;
+const uschar *headers_charset = US HEADERS_CHARSET;
int header_insert_maxlen = 64 * 1024;
header_line *header_last = NULL;
header_line *header_list = NULL;
each time a new feature is added (in a way that doesn't break backward
compatibility). */
-#define LOCAL_SCAN_ABI_VERSION_MAJOR 4
+#define LOCAL_SCAN_ABI_VERSION_MAJOR 5
#define LOCAL_SCAN_ABI_VERSION_MINOR 1
#define LOCAL_SCAN_ABI_VERSION \
LOCAL_SCAN_ABI_VERSION_MAJOR.LOCAL_SCAN_ABI_VERSION_MINOR
extern int body_linecount; /* Line count in body */
extern int body_zerocount; /* Binary zero count in body */
extern uschar *expand_string_message; /* Error info for failing expansion */
-extern uschar *headers_charset; /* Charset for RFC 2047 decoding */
+extern const uschar *headers_charset; /* Charset for RFC 2047 decoding */
extern header_line *header_last; /* Final header */
extern header_line *header_list; /* First header */
extern BOOL host_checking; /* Set when checking a host */
extern int lss_match_host(uschar *, uschar *, uschar *);
extern void receive_add_recipient(uschar *, int);
extern BOOL receive_remove_recipient(uschar *);
-extern uschar *rfc2047_decode(uschar *, BOOL, uschar *, int, int *, uschar **);
+extern uschar *rfc2047_decode(uschar *, BOOL, const uschar *, int, int *,
+ uschar **);
extern int smtp_fflush(void);
extern void smtp_printf(const char *, BOOL, ...) PRINTF_FUNCTION(1,3);
extern void smtp_vprintf(const char *, BOOL, va_list);
*/
const uschar *
-parse_quote_2047(const uschar *string, int len, uschar *charset, BOOL fold)
+parse_quote_2047(const uschar *string, int len, const uschar *charset,
+ BOOL fold)
{
const uschar * s = string;
int hlen, l;
*/
uschar *
-rfc2047_decode2(uschar *string, BOOL lencheck, uschar *target, int zeroval,
- int *lenptr, int *sizeptr, uschar **error)
+rfc2047_decode2(uschar *string, BOOL lencheck, const uschar *target,
+ int zeroval, int *lenptr, int *sizeptr, uschar **error)
{
int size = Ustrlen(string);
size_t dlen;
argument. */
uschar *
-rfc2047_decode(uschar *string, BOOL lencheck, uschar *target, int zeroval,
+rfc2047_decode(uschar *string, BOOL lencheck, const uschar *target, int zeroval,
int *lenptr, uschar **error)
{
return rfc2047_decode2(string, lencheck, target, zeroval, lenptr, NULL, error);