if (LOG != NULL)
{
- fseek(LOG, log_position, SEEK_SET);
+ if (fseek(LOG, log_position, SEEK_SET))
+ {
+ perror("logfile fseek");
+ exit(1);
+ }
while (Ufgets(buffer, log_buffer_len, LOG) != NULL)
{
{
if (LOG != NULL) fclose(LOG);
LOG = TEST;
- fstat(fileno(LOG), &statdata);
+ if (fstat(fileno(LOG), &statdata))
+ {
+ fprintf(stderr, "fstat %s: %s\n", log_file_open, strerror(errno));
+ exit(1);
+ }
log_inode = statdata.st_ino;
}
}
{
fseek(LOG, 0, SEEK_END);
log_position = ftell(LOG);
- fstat(fileno(LOG), &statdata);
- log_inode = statdata.st_ino;
+ if (fstat(fileno(LOG), &statdata))
+ {
+ perror("log file fstat");
+ fclose(LOG);
+ LOG=NULL;
+ }
+ else
+ log_inode = statdata.st_ino;
}
}
else
return;
}
-fcntl(pipe_fd[0], F_SETFL, O_NONBLOCK);
-fcntl(pipe_fd[1], F_SETFL, O_NONBLOCK);
+if ( fcntl(pipe_fd[0], F_SETFL, O_NONBLOCK)
+ || fcntl(pipe_fd[1], F_SETFL, O_NONBLOCK))
+ {
+ perror("set nonblocking on pipe");
+ exit(1);
+ }
/* Delivering a message can take some time, and we want to show the
output as it goes along. This requires subprocesses and is coded below. For
{
w = w; /* Keep picky compilers happy */
call_data = call_data;
-Ustrcpy(actioned_message, (uschar *)client_data);
+Ustrncpy(actioned_message, client_data, 24);
action_required = US"-Mar";
dialog_ref_widget = menushell;
create_dialog(US"Recipient address to add?", US"");
{
w = w; /* Keep picky compilers happy */
call_data = call_data;
-Ustrcpy(actioned_message, (uschar *)client_data);
+Ustrncpy(actioned_message, client_data, 24);
action_required = US"-Mmd";
dialog_ref_widget = menushell;
create_dialog(US"Recipient address to mark delivered?", US"");
{
w = w; /* Keep picky compilers happy */
call_data = call_data;
-ActOnMessage((uschar *)client_data, US"-Mmad", US"");
+ActOnMessage(US client_data, US"-Mmad", US"");
}
uschar *sender;
w = w; /* Keep picky compilers happy */
call_data = call_data;
-Ustrcpy(actioned_message, (uschar *)client_data);
+Ustrncpy(actioned_message, client_data, 24);
q = find_queue(actioned_message, queue_noop, 0);
-sender = (q == NULL)? US"" : (q->sender[0] == 0)? US"<>" : q->sender;
+sender = !q ? US"" : q->sender[0] == 0 ? US"<>" : q->sender;
action_required = US"-Mes";
dialog_ref_widget = menushell;
create_dialog(US"New sender address?", sender);
/* Sizes for integer arithmetic.
Go for 64bit; can be overridden in OS/Makefile-FOO
If you make it a different number of bits, provide a definition
-for EXIM_64B_MAX and _MIN in OS/oh.h-FOO */
+for EXIM_ARITH_MAX and _MIN in OS/oh.h-FOO */
#define int_eximarith_t int64_t
#define PR_EXIM_ARITH "%" PRId64 /* C99 standard, printf %lld */
#define SC_EXIM_ARITH "%" SCNi64 /* scanf incl. 0x prefix */
Sub array will be corrupted on return.
Returns: OK access is granted by an ACCEPT verb
- DISCARD access is granted by a DISCARD verb
+ DISCARD access is (apparently) granted by a DISCARD verb
FAIL access is denied
FAIL_DROP access is denied; drop the connection
DEFER can't tell at the moment
case 3: return NULL;
}
- *resetok = FALSE;
+ *resetok = FALSE; /* eval_acl() might allocate; do not reclaim */
if (yield != NULL) switch(eval_acl(sub, nelem(sub), &user_msg))
{
case OK:
case DEFER:
expand_string_forcedfail = TRUE;
+ /*FALLTHROUGH*/
default:
expand_string_message = string_sprintf("error from acl \"%s\"", sub[0]);
return NULL;
{
uschar *s = *sptr;
int_eximarith_t x = eval_op_mult(&s, decimal, error);
-if (*error == NULL)
+if (!*error)
{
while (*s == '+' || *s == '-')
{
int op = *s++;
int_eximarith_t y = eval_op_mult(&s, decimal, error);
- if (*error != NULL) break;
+ if (*error) break;
+ if ( (x >= EXIM_ARITH_MAX/2 && x >= EXIM_ARITH_MAX/2)
+ || (x <= -(EXIM_ARITH_MAX/2) && y <= -(EXIM_ARITH_MAX/2)))
+ { /* over-conservative check */
+ *error = op == '+'
+ ? US"overflow in sum" : US"overflow in difference";
+ break;
+ }
if (op == '+') x += y; else x -= y;
}
}
case DEFER:
expand_string_forcedfail = TRUE;
+ /*FALLTHROUGH*/
default:
expand_string_message = string_sprintf("error from acl \"%s\"", sub[0]);
goto EXPAND_FAILED;
extern int spam_ok;
int spool_mbox_ok = 0;
-uschar spooled_message_id[17];
+uschar spooled_message_id[MESSAGE_ID_LENGTH+1];
/* returns a pointer to the FILE, and puts the size in bytes into mbox_file_size
* normally, source_file_override is NULL */
(void)fclose(mbox_file);
mbox_file = NULL;
- Ustrcpy(spooled_message_id, message_id);
+ Ustrncpy(spooled_message_id, message_id, MESSAGE_ID_LENGTH+1);
spool_mbox_ok = 1;
}
for (i = 0; i < recipients_count; i++)
{
recipient_item *r = recipients_list + i;
-DEBUG(D_deliver) debug_printf("DSN: Flags :%d\n", r->dsn_flags);
+
+ DEBUG(D_deliver) debug_printf("DSN: Flags :%d\n", r->dsn_flags);
+
if (r->pno < 0 && r->errors_to == NULL && r->dsn_flags == 0)
fprintf(f, "%s\n", r->address);
else
{
- uschar *errors_to = (r->errors_to == NULL)? US"" : r->errors_to;
+ uschar * errors_to = r->errors_to ? r->errors_to : US"";
/* for DSN SUPPORT extend exim 4 spool in a compatible way by
- adding new values upfront and add flag 0x02 */
- uschar *orcpt = (r->orcpt == NULL)? US"" : r->orcpt;
- fprintf(f, "%s %s %d,%d %s %d,%d#3\n", r->address, orcpt, Ustrlen(orcpt), r->dsn_flags,
- errors_to, Ustrlen(errors_to), r->pno);
+ adding new values upfront and add flag 0x02 */
+ uschar * orcpt = r->orcpt ? r->orcpt : US"";
+
+ fprintf(f, "%s %s %d,%d %s %d,%d#3\n", r->address, orcpt, Ustrlen(orcpt),
+ r->dsn_flags, errors_to, Ustrlen(errors_to), r->pno);
}
- DEBUG(D_deliver) debug_printf("DSN: **** SPOOL_OUT - address: |%s| errorsto: |%s| orcpt: |%s| dsn_flags: %d\n",
- r->address, r->errors_to, r->orcpt, r->dsn_flags);
+ DEBUG(D_deliver) debug_printf("DSN: **** SPOOL_OUT - "
+ "address: |%s| errorsto: |%s| orcpt: |%s| dsn_flags: %d\n",
+ r->address, r->errors_to, r->orcpt, r->dsn_flags);
}
/* Put a blank line before the headers */
to get the actual size of the headers. */
fflush(f);
-fstat(fd, &statbuf);
+if (fstat(fd, &statbuf))
+ return spool_write_error(where, errmsg, US"fstat", temp_name, f);
size_correction = statbuf.st_size;
/* Finally, write out the message's headers. To make it easier to read them