diff options
-rw-r--r-- | src/src/exim.c | 2 | ||||
-rw-r--r-- | src/src/functions.h | 15 | ||||
-rw-r--r-- | src/src/parse.c | 6 | ||||
-rw-r--r-- | src/src/rda.c | 26 | ||||
-rw-r--r-- | src/src/sieve.c | 65 |
5 files changed, 53 insertions, 61 deletions
diff --git a/src/src/exim.c b/src/src/exim.c index b9b1c9a7d..bedac628b 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -739,7 +739,7 @@ Returns: nothing; bombs out on failure */ void -exim_setugid(uid_t uid, gid_t gid, BOOL igflag, uschar *msg) +exim_setugid(uid_t uid, gid_t gid, BOOL igflag, const uschar * msg) { uid_t euid = geteuid(); gid_t egid = getegid(); diff --git a/src/src/functions.h b/src/src/functions.h index 9c222223b..c03f88304 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -248,7 +248,7 @@ extern const uschar * exim_errstr(int); extern void exim_exit(int) NORETURN; extern void exim_gettime(struct timeval *); extern void exim_nullstd(void); -extern void exim_setugid(uid_t, gid_t, BOOL, uschar *); +extern void exim_setugid(uid_t, gid_t, BOOL, const uschar *); extern void exim_underbar_exit(int) NORETURN; extern void exim_wait_tick(struct timeval *, int); extern int exp_bool(address_item *addr, @@ -378,7 +378,7 @@ extern int open_cutthrough_connection( address_item * addr ); extern uschar *parse_extract_address(const uschar *, uschar **, int *, int *, int *, BOOL); extern int parse_forward_list(const uschar *, int, address_item **, uschar **, - const uschar *, uschar *, error_block **); + const uschar *, const uschar *, error_block **); extern uschar *parse_find_address_end(const uschar *, BOOL); extern const uschar *parse_find_at(const uschar *); extern const uschar *parse_fix_phrase(const uschar *, int); @@ -405,9 +405,9 @@ extern void queue_run(uschar *, uschar *, BOOL); extern int random_number(int); extern const uschar *rc_to_string(int); -extern int rda_interpret(redirect_block *, int, uschar *, uschar *, - uschar *, uschar *, uschar *, ugid_block *, address_item **, - uschar **, error_block **, int *, uschar *); +extern int rda_interpret(redirect_block *, int, const uschar *, const uschar *, + const uschar *, const uschar *, const uschar *, const ugid_block *, address_item **, + uschar **, error_block **, int *, const uschar *); extern int rda_is_filter(const uschar *); extern BOOL readconf_depends(driver_instance *, uschar *); extern void readconf_driver_init(uschar *, driver_instance **, @@ -478,8 +478,9 @@ extern void set_process_info(const char *, ...) PRINTF_FUNCTION(1,2); extern void sha1_end(hctx *, const uschar *, int, uschar *); extern void sha1_mid(hctx *, const uschar *); extern void sha1_start(hctx *); -extern int sieve_interpret(const uschar *, int, uschar *, uschar *, uschar *, - uschar *, address_item **, uschar **); +extern int sieve_interpret(const uschar *, int, const uschar *, + const uschar *, const uschar *, const uschar *, + address_item **, uschar **); extern void sigalrm_handler(int); extern void smtp_closedown(uschar *); extern void smtp_command_timeout_exit(void) NORETURN; diff --git a/src/src/parse.c b/src/src/parse.c index 8c1badd08..fcea2ea26 100644 --- a/src/src/parse.c +++ b/src/src/parse.c @@ -1243,7 +1243,7 @@ Returns: FF_DELIVERED addresses extracted int parse_forward_list(const uschar *s, int options, address_item **anchor, - uschar **error, const uschar *incoming_domain, uschar *directory, + uschar **error, const uschar *incoming_domain, const uschar *directory, error_block **syntax_errors) { int count = 0; @@ -1388,7 +1388,7 @@ for (;;) return FF_ERROR; } - if (flen > 255) + if (flen > sizeof(filename)-1) { *error = string_sprintf("included file name \"%s\" is too long", t); return FF_ERROR; @@ -1438,7 +1438,7 @@ for (;;) with a flag that fails symlinks. */ { - int fd = exim_open2(CS directory, O_RDONLY); + int fd = exim_open2(CCS directory, O_RDONLY); if (fd < 0) { *error = string_sprintf("failed to open directory %s", directory); diff --git a/src/src/rda.c b/src/src/rda.c index 35794c2ff..0ffc61c77 100644 --- a/src/src/rda.c +++ b/src/src/rda.c @@ -337,11 +337,11 @@ Returns: a suitable return for rda_interpret() */ static int -rda_extract(const redirect_block *rdata, int options, uschar *include_directory, - uschar *sieve_vacation_directory, uschar *sieve_enotify_mailto_owner, - uschar *sieve_useraddress, uschar *sieve_subaddress, - address_item **generated, uschar **error, error_block **eblockp, - int *filtertype) +rda_extract(const redirect_block * rdata, int options, + const uschar * include_directory, const uschar * sieve_vacation_directory, + const uschar * sieve_enotify_mailto_owner, const uschar * sieve_useraddress, + const uschar * sieve_subaddress, address_item ** generated, uschar ** error, + error_block ** eblockp, int * filtertype) { const uschar * data; @@ -440,9 +440,9 @@ Returns: -1 on error, else 0 static int rda_write_string(int fd, const uschar *s) { -int len = (s == NULL)? 0 : Ustrlen(s) + 1; +int len = s ? Ustrlen(s) + 1 : 0; return ( write(fd, &len, sizeof(int)) != sizeof(int) - || (s != NULL && write(fd, s, len) != len) + || (s && write(fd, s, len) != len) ) ? -1 : 0; } @@ -539,11 +539,11 @@ Returns: values from extraction function, or FF_NONEXIST: */ int -rda_interpret(redirect_block *rdata, int options, uschar *include_directory, - uschar *sieve_vacation_directory, uschar *sieve_enotify_mailto_owner, - uschar *sieve_useraddress, uschar *sieve_subaddress, ugid_block *ugid, - address_item **generated, uschar **error, error_block **eblockp, - int *filtertype, uschar *rname) +rda_interpret(redirect_block * rdata, int options, + const uschar * include_directory, const uschar * sieve_vacation_directory, + const uschar * sieve_enotify_mailto_owner, const uschar * sieve_useraddress, + const uschar * sieve_subaddress, const ugid_block * ugid, address_item ** generated, + uschar ** error, error_block ** eblockp, int * filtertype, const uschar * rname) { int fd, rc, pfd[2]; int yield, status; @@ -964,11 +964,9 @@ if (had_disaster) log_write(0, LOG_MAIN|LOG_PANIC, "%s", *error); } else if (status != 0) - { log_write(0, LOG_MAIN|LOG_PANIC, "internal problem in %s: unexpected status " "%04x from redirect subprocess (but data correctly received)", rname, status); - } FINAL_EXIT: (void)close(fd); diff --git a/src/src/sieve.c b/src/src/sieve.c index b6b4ec6c4..f693ebf4e 100644 --- a/src/src/sieve.c +++ b/src/src/sieve.c @@ -71,7 +71,7 @@ struct Sieve int require_enotify; struct Notification *notified; #endif - uschar *enotify_mailto_owner; + const uschar *enotify_mailto_owner; #ifdef SUBADDRESS int require_subaddress; #endif @@ -79,7 +79,7 @@ struct Sieve int require_vacation; int vacation_ran; #endif - uschar *vacation_directory; + const uschar *vacation_directory; const uschar *subaddress; const uschar *useraddress; int require_copy; @@ -3093,9 +3093,9 @@ while (*filter->pc) ? expand_string(US"$local_part_prefix$local_part$local_part_suffix@$domain") : from.character); for (string_item * p = recipient; p; p=p->next) - fprintf(f,"To: %s\n",p->text); - fprintf(f,"Auto-Submitted: auto-notified; %s\n",filter->enotify_mailto_owner); - if (header.length>0) fprintf(f,"%s",header.character); + fprintf(f, "To: %s\n",p->text); + fprintf(f, "Auto-Submitted: auto-notified; %s\n", filter->enotify_mailto_owner); + if (header.length > 0) fprintf(f, "%s", header.character); if (message.length==-1) { message.character=US"Notification"; @@ -3105,7 +3105,7 @@ while (*filter->pc) fprintf(f, "Subject: %s\n", parse_quote_2047(message.character, message.length, US"utf-8", TRUE)); fprintf(f,"\n"); - if (body.length>0) fprintf(f,"%s\n",body.character); + if (body.length > 0) fprintf(f, "%s\n", body.character); fflush(f); (void)fclose(f); (void)child_close(pid, 0); @@ -3425,7 +3425,7 @@ filter->require_iascii_numeric=0; if (parse_white(filter)==-1) return -1; -if (exec && filter->vacation_directory != NULL && filter_test == FTEST_NONE) +if (exec && filter->vacation_directory && filter_test == FTEST_NONE) { DIR *oncelogdir; struct dirent *oncelog; @@ -3448,8 +3448,8 @@ if (exec && filter->vacation_directory != NULL && filter_test == FTEST_NONE) while ((oncelog = readdir(oncelogdir))) if (strlen(oncelog->d_name)==32) { - uschar *s = string_sprintf("%s/%s",filter->vacation_directory,oncelog->d_name); - if (Ustat(s,&properties)==0 && (properties.st_mtime+VACATION_MAX_DAYS*86400)<now) + uschar *s = string_sprintf("%s/%s", filter->vacation_directory, oncelog->d_name); + if (Ustat(s,&properties) == 0 && properties.st_mtime+VACATION_MAX_DAYS*86400 < now) Uunlink(s); } closedir(oncelogdir); @@ -3484,7 +3484,7 @@ while (parse_identifier(filter,CUS "require")) #ifdef ENOTIFY else if (eq_octet(check,&str_enotify,0)) { - if (filter->enotify_mailto_owner == NULL) + if (!filter->enotify_mailto_owner) { filter->errmsg=CUS "enotify disabled"; return -1; @@ -3498,7 +3498,7 @@ while (parse_identifier(filter,CUS "require")) #ifdef VACATION else if (eq_octet(check,&str_vacation,0)) { - if (filter_test == FTEST_NONE && filter->vacation_directory == NULL) + if (filter_test == FTEST_NONE && !filter->vacation_directory) { filter->errmsg=CUS "vacation disabled"; return -1; @@ -3554,41 +3554,36 @@ Returns: FF_DELIVERED success, a significant action was taken */ int -sieve_interpret(const uschar *filter, int options, uschar *vacation_directory, - uschar *enotify_mailto_owner, uschar *useraddress, uschar *subaddress, - address_item **generated, uschar **error) +sieve_interpret(const uschar * filter, int options, + const uschar * vacation_directory, const uschar * enotify_mailto_owner, + const uschar * useraddress, const uschar * subaddress, + address_item ** generated, uschar ** error) { struct Sieve sieve; int r; -uschar *msg; +uschar * msg; DEBUG(D_route) debug_printf("Sieve: start of processing\n"); sieve.filter = filter; if (!vacation_directory) sieve.vacation_directory = NULL; -else +else if (!(sieve.vacation_directory = expand_cstring(vacation_directory))) { - if (!(sieve.vacation_directory = expand_string(vacation_directory))) - { - *error = string_sprintf("failed to expand \"%s\" " - "(sieve_vacation_directory): %s", vacation_directory, - expand_string_message); - return FF_ERROR; - } + *error = string_sprintf("failed to expand \"%s\" " + "(sieve_vacation_directory): %s", vacation_directory, + expand_string_message); + return FF_ERROR; } if (!enotify_mailto_owner) sieve.enotify_mailto_owner = NULL; -else +else if (!(sieve.enotify_mailto_owner = expand_cstring(enotify_mailto_owner))) { - if (!(sieve.enotify_mailto_owner = expand_string(enotify_mailto_owner))) - { - *error = string_sprintf("failed to expand \"%s\" " - "(sieve_enotify_mailto_owner): %s", enotify_mailto_owner, - expand_string_message); - return FF_ERROR; - } + *error = string_sprintf("failed to expand \"%s\" " + "(sieve_enotify_mailto_owner): %s", enotify_mailto_owner, + expand_string_message); + return FF_ERROR; } sieve.useraddress = useraddress @@ -3596,14 +3591,13 @@ sieve.useraddress = useraddress sieve.subaddress = subaddress; #ifdef COMPILE_SYNTAX_CHECKER -if (parse_start(&sieve,0,generated)==1) +if (parse_start(&sieve, 0, generated) == 1) #else -if (parse_start(&sieve,1,generated)==1) +if (parse_start(&sieve, 1, generated) == 1) #endif - { if (sieve.keep) { - add_addr(generated,US"inbox",1,0,0,0); + add_addr(generated, US"inbox", 1, 0, 0, 0); msg = US"Implicit keep"; r = FF_DELIVERED; } @@ -3612,7 +3606,6 @@ if (parse_start(&sieve,1,generated)==1) msg = US"No implicit keep"; r = FF_DELIVERED; } - } else { msg = string_sprintf("Sieve error: %s in line %d",sieve.errmsg,sieve.line); |