X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Fexim.c;h=32bd3968fae6b2345bb2b5ca9a675a77153ff275;hb=9c5e54499afef5167bee6ecdcbf8dd5f023f51e0;hp=b6d926b50d7ef3660fa67273764b8f3e2a6ddd5a;hpb=3b7ac02caeb878252361e602dc46e96104f773a9;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/exim.c b/src/src/exim.c index b6d926b50..32bd3968f 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -140,14 +140,13 @@ regex_match_and_setup(const pcre *re, const uschar *subject, int options, int se int ovector[3*(EXPAND_MAXN+1)]; uschar * s = string_copy(subject); /* de-constifying */ int n = pcre_exec(re, NULL, CS s, Ustrlen(s), 0, - PCRE_EOPT | options, ovector, sizeof(ovector)/sizeof(int)); + PCRE_EOPT | options, ovector, nelem(ovector)); BOOL yield = n >= 0; if (n == 0) n = EXPAND_MAXN + 1; if (yield) { - int nn; - expand_nmax = (setup < 0)? 0 : setup + 1; - for (nn = (setup < 0)? 0 : 2; nn < n*2; nn += 2) + expand_nmax = setup < 0 ? 0 : setup + 1; + for (int nn = setup < 0 ? 0 : 2; nn < n*2; nn += 2) { expand_nstring[expand_nmax] = s + ovector[nn]; expand_nlength[expand_nmax++] = ovector[nn+1] - ovector[nn]; @@ -174,15 +173,22 @@ Returns: nothing void set_process_info(const char *format, ...) { -int len = sprintf(CS process_info, "%5d ", (int)getpid()); +gstring gs = { .size = PROCESS_INFO_SIZE - 2, .ptr = 0, .s = process_info }; +gstring * g; +int len; va_list ap; + +g = string_fmt_append(&gs, "%5d ", (int)getpid()); +len = g->ptr; va_start(ap, format); -if (!string_vformat(process_info + len, PROCESS_INFO_SIZE - len - 2, format, ap)) - Ustrcpy(process_info + len, "**** string overflowed buffer ****"); -len = Ustrlen(process_info); -process_info[len+0] = '\n'; -process_info[len+1] = '\0'; -process_info_len = len + 1; +if (!string_vformat(g, FALSE, format, ap)) + { + gs.ptr = len; + g = string_cat(&gs, US"**** string overflowed buffer ****"); + } +g = string_catn(g, US"\n", 1); +string_from_gstring(g); +process_info_len = g->ptr; DEBUG(D_process_info) debug_printf("set_process_info: %s", process_info); va_end(ap); } @@ -490,10 +496,9 @@ Returns: Nothing void exim_nullstd(void) { -int i; int devnull = -1; struct stat statbuf; -for (i = 0; i <= 2; i++) +for (int i = 0; i <= 2; i++) { if (fstat(i, &statbuf) < 0 && errno == EBADF) { @@ -635,10 +640,7 @@ DEBUG(D_uid) save_errno = errno; debug_printf(" auxiliary group list:"); if (group_count > 0) - { - int i; - for (i = 0; i < group_count; i++) debug_printf(" %d", (int)group_list[i]); - } + for (int i = 0; i < group_count; i++) debug_printf(" %d", (int)group_list[i]); else if (group_count < 0) debug_printf(" ", strerror(save_errno)); else debug_printf(" "); @@ -800,8 +802,6 @@ Returns: nothing static void show_whats_supported(FILE * fp) { -auth_info * authi; - DEBUG(D_any) {} else show_db_version(fp); fprintf(fp, "Support for:"); @@ -906,6 +906,9 @@ fprintf(fp, "Support for:"); #ifdef EXPERIMENTAL_REQUIRETLS fprintf(fp, " Experimental_REQUIRETLS"); #endif +#ifdef EXPERIMENTAL_PIPE_CONNECT + fprintf(fp, " Experimental_PIPE_CONNECT"); +#endif fprintf(fp, "\n"); fprintf(fp, "Lookups (built-in):"); @@ -927,6 +930,9 @@ fprintf(fp, "Lookups (built-in):"); #if defined(LOOKUP_IBASE) && LOOKUP_IBASE!=2 fprintf(fp, " ibase"); #endif +#if defined(LOOKUP_JSON) && LOOKUP_JSON!=2 + fprintf(fp, " json"); +#endif #if defined(LOOKUP_LDAP) && LOOKUP_LDAP!=2 fprintf(fp, " ldap ldapdn ldapm"); #endif @@ -990,8 +996,6 @@ fprintf(fp, "Size of off_t: " SIZE_T_FMT "\n", sizeof(off_t)); Perhaps the tls_version_report should move into this too. */ DEBUG(D_any) do { - int i; - /* clang defines __GNUC__ (at least, for me) so test for it first */ #if defined(__clang__) fprintf(fp, "Compiler: CLang [%s]\n", __clang_version__); @@ -1024,7 +1028,7 @@ show_db_version(fp); utf8_version_report(fp); #endif - for (authi = auths_available; *authi->driver_name != '\0'; ++authi) + for (auth_info * authi = auths_available; *authi->driver_name != '\0'; ++authi) if (authi->version_report) (*authi->version_report)(fp); @@ -1045,7 +1049,7 @@ show_db_version(fp); #undef EXPAND_AND_QUOTE init_lookup_list(); - for (i = 0; i < lookup_list_count; i++) + for (int i = 0; i < lookup_list_count; i++) if (lookup_list[i]->version_report) lookup_list[i]->version_report(fp); @@ -1071,8 +1075,6 @@ show_db_version(fp); static void show_exim_information(enum commandline_info request, FILE *stream) { -const uschar **pp; - switch(request) { case CMDINFO_NONE: @@ -1089,7 +1091,7 @@ switch(request) ); return; case CMDINFO_SIEVE: - for (pp = exim_sieve_extension_list; *pp; ++pp) + for (const uschar ** pp = exim_sieve_extension_list; *pp; ++pp) fprintf(stream, "%s\n", *pp); return; case CMDINFO_DSCP: @@ -1116,9 +1118,8 @@ local_part_quote(uschar *lpart) { BOOL needs_quote = FALSE; gstring * g; -uschar *t; -for (t = lpart; !needs_quote && *t != 0; t++) +for (uschar * t = lpart; !needs_quote && *t != 0; t++) { needs_quote = !isalnum(*t) && strchr("!#$%&'*+-/=?^_`{|}~", *t) == NULL && (*t != '.' || t == lpart || t[1] == 0); @@ -1215,12 +1216,11 @@ Returns: pointer to dynamic memory, or NULL at end of file static uschar * get_stdinput(char *(*fn_readline)(const char *), void(*fn_addhist)(const char *)) { -int i; gstring * g = NULL; if (!fn_readline) { printf("> "); fflush(stdout); } -for (i = 0;; i++) +for (int i = 0;; i++) { uschar buffer[1024]; uschar *p, *ss; @@ -1320,8 +1320,7 @@ static BOOL macros_trusted(BOOL opt_D_used) { #ifdef WHITELIST_D_MACROS -macro_item *m; -uschar *whitelisted, *end, *p, **whites, **w; +uschar *whitelisted, *end, *p, **whites; int white_count, i, n; size_t len; BOOL prev_char_item, found; @@ -1386,10 +1385,10 @@ whites[i] = NULL; /* The list of commandline macros should be very short. Accept the N*M complexity. */ -for (m = macros_user; m; m = m->next) if (m->command_line) +for (macro_item * m = macros_user; m; m = m->next) if (m->command_line) { found = FALSE; - for (w = whites; *w; ++w) + for (uschar ** w = whites; *w; ++w) if (Ustrcmp(*w, m->name) == 0) { found = TRUE; @@ -2812,8 +2811,7 @@ for (i = 1; i < argc; i++) if (!one_msg_action) { - int j; - for (j = msg_action_arg; j < argc; j++) if (!mac_ismsgid(argv[j])) + for (int j = msg_action_arg; j < argc; j++) if (!mac_ismsgid(argv[j])) exim_fail("exim: malformed message id %s after %s option\n", argv[j], arg); goto END_ARG; /* Remaining args are ids */ @@ -3209,9 +3207,7 @@ for (i = 1; i < argc; i++) argument. */ if (*argrest != 0) - { - int i; - for (i = 0; i < nelem(rsopts); i++) + for (int i = 0; i < nelem(rsopts); i++) if (Ustrcmp(argrest, rsopts[i]) == 0) { if (i != 2) f.queue_run_force = TRUE; @@ -3219,7 +3215,6 @@ for (i = 1; i < argc; i++) if (i == 1 || i == 4) f.deliver_force_thaw = TRUE; argrest += Ustrlen(rsopts[i]); } - } /* -R: Set string to match in addresses for forced queue run to pick out particular messages. */ @@ -3251,9 +3246,7 @@ for (i = 1; i < argc; i++) argument. */ if (*argrest) - { - int i; - for (i = 0; i < nelem(rsopts); i++) + for (int i = 0; i < nelem(rsopts); i++) if (Ustrcmp(argrest, rsopts[i]) == 0) { if (i != 2) f.queue_run_force = TRUE; @@ -3261,7 +3254,6 @@ for (i = 1; i < argc; i++) if (i == 1 || i == 4) f.deliver_force_thaw = TRUE; argrest += Ustrlen(rsopts[i]); } - } /* -S: Set string to match in addresses for forced queue run to pick out particular messages. */ @@ -3690,16 +3682,13 @@ for later interrogation. */ if (real_uid == root_uid || real_uid == exim_uid || real_gid == exim_gid) f.admin_user = TRUE; else - { - int i, j; - for (i = 0; i < group_count && !f.admin_user; i++) + for (int i = 0; i < group_count && !f.admin_user; i++) if (group_list[i] == exim_gid) f.admin_user = TRUE; else if (admin_groups) - for (j = 1; j <= (int)admin_groups[0] && !f.admin_user; j++) + for (int j = 1; j <= (int)admin_groups[0] && !f.admin_user; j++) if (admin_groups[j] == group_list[i]) f.admin_user = TRUE; - } /* Another group of privileged users are the trusted users. These are root, exim, and any caller matching trusted_users or trusted_groups. Trusted callers @@ -3710,18 +3699,16 @@ if (real_uid == root_uid || real_uid == exim_uid) f.trusted_caller = TRUE; else { - int i, j; - if (trusted_users) - for (i = 1; i <= (int)trusted_users[0] && !f.trusted_caller; i++) + for (int i = 1; i <= (int)trusted_users[0] && !f.trusted_caller; i++) if (trusted_users[i] == real_uid) f.trusted_caller = TRUE; if (trusted_groups) - for (i = 1; i <= (int)trusted_groups[0] && !f.trusted_caller; i++) + for (int i = 1; i <= (int)trusted_groups[0] && !f.trusted_caller; i++) if (trusted_groups[i] == real_gid) f.trusted_caller = TRUE; - else for (j = 0; j < group_count && !f.trusted_caller; j++) + else for (int j = 0; j < group_count && !f.trusted_caller; j++) if (trusted_groups[i] == group_list[j]) f.trusted_caller = TRUE; } @@ -3739,10 +3726,9 @@ decode_bits(log_selector, log_selector_size, log_notall, DEBUG(D_any) { - int i; debug_printf("configuration file is %s\n", config_main_filename); debug_printf("log selectors ="); - for (i = 0; i < log_selector_size; i++) + for (int i = 0; i < log_selector_size; i++) debug_printf(" %08x", log_selector[i]); debug_printf("\n"); } @@ -3819,9 +3805,7 @@ EXIM_TMPDIR by the build scripts. */ #ifdef EXIM_TMPDIR - { - uschar **p; - if (environ) for (p = USS environ; *p; p++) + if (environ) for (uschar ** p = USS environ; *p; p++) if (Ustrncmp(*p, "TMPDIR=", 7) == 0 && Ustrcmp(*p+7, EXIM_TMPDIR) != 0) { uschar * newp = store_malloc(Ustrlen(EXIM_TMPDIR) + 8); @@ -3829,7 +3813,6 @@ EXIM_TMPDIR by the build scripts. *p = newp; DEBUG(D_any) debug_printf("reset TMPDIR=%s in environment\n", EXIM_TMPDIR); } - } #endif /* Timezone handling. If timezone_string is "utc", set a flag to cause all @@ -3931,7 +3914,6 @@ verifying/testing addresses or expansions. */ if ( (debug_selector & D_any || LOGGING(arguments)) && f.really_exim && !list_options && !checking) { - int i; uschar *p = big_buffer; Ustrcpy(p, "cwd= (failed)"); @@ -3948,7 +3930,7 @@ if ( (debug_selector & D_any || LOGGING(arguments)) (void)string_format(p, big_buffer_size - (p - big_buffer), " %d args:", argc); while (*p) p++; - for (i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) { int len = Ustrlen(argv[i]); const uschar *printing; @@ -4366,7 +4348,6 @@ if (test_retry_arg >= 0) printf("No retry information found\n"); else { - retry_rule *r; more_errno = yield->more_errno; printf("Retry rule: %s ", yield->pattern); @@ -4396,7 +4377,7 @@ if (test_retry_arg >= 0) printf("auth_failed "); else printf("* "); - for (r = yield->rules; r; r = r->next) + for (retry_rule * r = yield->rules; r; r = r->next) { printf("%c,%s", r->rule, readconf_printtime(r->timeout)); /* Do not */ printf(",%s", readconf_printtime(r->p1)); /* amalgamate */ @@ -5272,7 +5253,6 @@ while (more) else { - int i; int rcount = 0; int count = argc - recipients_arg; uschar **list = argv + recipients_arg; @@ -5288,7 +5268,7 @@ while (more) /* Loop for each argument */ - for (i = 0; i < count; i++) + for (int i = 0; i < count; i++) { int start, end, domain; uschar *errmess; @@ -5370,12 +5350,11 @@ while (more) DEBUG(D_receive) { - int i; if (sender_address != NULL) debug_printf("Sender: %s\n", sender_address); if (recipients_list != NULL) { debug_printf("Recipients:\n"); - for (i = 0; i < recipients_count; i++) + for (int i = 0; i < recipients_count; i++) debug_printf(" %s\n", recipients_list[i].address); } } @@ -5634,7 +5613,7 @@ moreloop: callout_address = NULL; sending_ip_address = NULL; acl_var_m = NULL; - { int i; for(i=0; i