diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2014-06-06 15:58:54 +0100 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2014-06-06 15:58:54 +0100 |
commit | 19050083522f210e8bb4f1a5ba03928ed0077a49 (patch) | |
tree | 4eac48d95b02cfa6ad761e5a223559faed438d8c | |
parent | a6d4c44ef48936ac169cd0da7ea149cbc81c9716 (diff) |
More care with time types
-rw-r--r-- | src/exim_monitor/em_globals.c | 2 | ||||
-rw-r--r-- | src/src/deliver.c | 11 | ||||
-rw-r--r-- | src/src/dmarc.c | 2 | ||||
-rw-r--r-- | src/src/exim_lock.c | 6 | ||||
-rw-r--r-- | src/src/globals.c | 2 | ||||
-rw-r--r-- | src/src/globals.h | 2 | ||||
-rw-r--r-- | src/src/ip.c | 2 | ||||
-rw-r--r-- | src/src/smtp_in.c | 3 | ||||
-rw-r--r-- | src/src/spool_in.c | 2 | ||||
-rw-r--r-- | src/src/spool_out.c | 2 | ||||
-rw-r--r-- | src/src/tod.c | 4 | ||||
-rw-r--r-- | src/src/transports/appendfile.c | 1 |
12 files changed, 20 insertions, 19 deletions
diff --git a/src/exim_monitor/em_globals.c b/src/exim_monitor/em_globals.c index d5205d08f..671bd7f03 100644 --- a/src/exim_monitor/em_globals.c +++ b/src/exim_monitor/em_globals.c @@ -130,7 +130,7 @@ int body_zerocount = 0; BOOL deliver_firsttime = FALSE; BOOL deliver_freeze = FALSE; -int deliver_frozen_at = 0; +time_t deliver_frozen_at = 0; BOOL deliver_manual_thaw = FALSE; #ifndef DISABLE_DKIM diff --git a/src/src/deliver.c b/src/src/deliver.c index c2f769da6..32cba9a91 100644 --- a/src/src/deliver.c +++ b/src/src/deliver.c @@ -863,16 +863,12 @@ if (log_extra_selector & LX_smtp_confirmation && /* Time on queue and actual time taken to deliver */ if ((log_extra_selector & LX_queue_time) != 0) - { s = string_append(s, &size, &ptr, 2, US" QT=", - readconf_printtime(time(NULL) - received_time)); - } + readconf_printtime( (int) ((long)time(NULL) - (long)received_time)) ); if ((log_extra_selector & LX_deliver_time) != 0) - { s = string_append(s, &size, &ptr, 2, US" DT=", readconf_printtime(addr->more_errno)); - } /* string_cat() always leaves room for the terminator. Release the store we used to build the line after writing it. */ @@ -6497,7 +6493,8 @@ if (addr_senddsn != NULL) DEBUG(D_deliver) debug_printf("sending error message to: %s\n", sender_address); /* build unique id for MIME boundary */ - snprintf(boundaryStr, 63, "%l-eximdsn-%d", (long) time(NULL), rand()); + snprintf(boundaryStr, sizeof(boundaryStr)-1, TIME_T_FMT "-eximdsn-%d", + time(NULL), rand()); DEBUG(D_deliver) debug_printf("DSN: MIME boundary: %s\n", boundaryStr); if (errors_reply_to != NULL) fprintf(f,"Reply-To: %s\n", errors_reply_to); @@ -7172,7 +7169,7 @@ if (addr_defer == NULL) if ((log_extra_selector & LX_queue_time_overall) != 0) log_write(0, LOG_MAIN, "Completed QT=%s", - readconf_printtime(time(NULL) - received_time)); + readconf_printtime( (int) ((long)time(NULL) - (long)received_time)) ); else log_write(0, LOG_MAIN, "Completed"); diff --git a/src/src/dmarc.c b/src/src/dmarc.c index ca1c29bbb..bc2ea4c08 100644 --- a/src/src/dmarc.c +++ b/src/src/dmarc.c @@ -451,7 +451,7 @@ int dmarc_write_history_file() /* Generate the contents of the history file */ history_buffer = string_sprintf("job %s\n", message_id); history_buffer = string_sprintf("%sreporter %s\n", history_buffer, primary_hostname); - history_buffer = string_sprintf("%sreceived %ld\n", history_buffer, time(NULL)); + history_buffer = string_sprintf("%sreceived " TIME_T_FMT "\n", history_buffer, time(NULL)); history_buffer = string_sprintf("%sipaddr %s\n", history_buffer, sender_host_address); history_buffer = string_sprintf("%sfrom %s\n", history_buffer, header_from_sender); history_buffer = string_sprintf("%smfrom %s\n", history_buffer, diff --git a/src/src/exim_lock.c b/src/src/exim_lock.c index 0d3475138..37d974477 100644 --- a/src/src/exim_lock.c +++ b/src/src/exim_lock.c @@ -175,7 +175,7 @@ int fd = -1; int hd = -1; int md = -1; int yield = 0; -int now = time(NULL); +time_t now = time(NULL); BOOL use_lockfile = FALSE; BOOL use_fcntl = FALSE; BOOL use_flock = FALSE; @@ -300,8 +300,10 @@ if (use_lockfile) lockname = malloc(len + 8); sprintf(lockname, "%s.lock", filename); hitchname = malloc(len + 32 + (int)strlen(primary_hostname)); + + /* Presumably, this must match appendfile.c */ sprintf(hitchname, "%s.%s.%08x.%08x", lockname, primary_hostname, - now, (int)getpid()); + (unsigned int)now, (unsigned int)getpid()); if (verbose) printf("exim_lock: lockname = %s\n hitchname = %s\n", lockname, diff --git a/src/src/globals.c b/src/src/globals.c index 761db6181..d3f99877c 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -573,7 +573,7 @@ BOOL deliver_drop_privilege = FALSE; BOOL deliver_firsttime = FALSE; BOOL deliver_force = FALSE; BOOL deliver_freeze = FALSE; -int deliver_frozen_at = 0; +time_t deliver_frozen_at = 0; uschar *deliver_home = NULL; uschar *deliver_host = NULL; uschar *deliver_host_address = NULL; diff --git a/src/src/globals.h b/src/src/globals.h index cf9b61eff..2bedcf523 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -323,7 +323,7 @@ extern BOOL deliver_drop_privilege; /* TRUE for unprivileged delivery */ extern BOOL deliver_firsttime; /* True for first delivery attempt */ extern BOOL deliver_force; /* TRUE if delivery was forced */ extern BOOL deliver_freeze; /* TRUE if delivery is frozen */ -extern int deliver_frozen_at; /* Time of freezing */ +extern time_t deliver_frozen_at; /* Time of freezing */ extern uschar *deliver_home; /* Home directory for pipes */ extern uschar *deliver_host; /* (First) host for routed local deliveries */ /* Remote host for filter */ diff --git a/src/src/ip.c b/src/src/ip.c index 1d4e368ec..b492b9da1 100644 --- a/src/src/ip.c +++ b/src/src/ip.c @@ -403,7 +403,7 @@ ip_recv(int sock, uschar *buffer, int buffsize, int timeout) { fd_set select_inset; struct timeval tv; -int start_recv = time(NULL); +time_t start_recv = time(NULL); int rc; /* Wait until the socket is ready */ diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index 4ea6cd404..dbaa3280c 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -1317,7 +1317,8 @@ for (i = 0; i < smtp_ch_index; i++) if (s != NULL) s[ptr] = 0; else s = US""; log_write(0, LOG_MAIN, "no MAIL in SMTP connection from %s D=%s%s", host_and_ident(FALSE), - readconf_printtime(time(NULL) - smtp_connection_start), s); + readconf_printtime( (int) ((long)time(NULL) - (long)smtp_connection_start)), + s); } diff --git a/src/src/spool_in.c b/src/src/spool_in.c index 5e604fa15..6dcb512e4 100644 --- a/src/src/spool_in.c +++ b/src/src/spool_in.c @@ -492,7 +492,7 @@ for (;;) if (Ustrncmp(p, "rozen", 5) == 0) { deliver_freeze = TRUE; - deliver_frozen_at = Uatoi(big_buffer + 7); + sscanf(big_buffer+7, TIME_T_FMT, &deliver_frozen_at); } break; diff --git a/src/src/spool_out.c b/src/src/spool_out.c index 01b70341d..67ac8bce7 100644 --- a/src/src/spool_out.c +++ b/src/src/spool_out.c @@ -210,7 +210,7 @@ if (authenticated_sender != NULL) if (allow_unqualified_recipient) fprintf(f, "-allow_unqualified_recipient\n"); if (allow_unqualified_sender) fprintf(f, "-allow_unqualified_sender\n"); if (deliver_firsttime) fprintf(f, "-deliver_firsttime\n"); -if (deliver_freeze) fprintf(f, "-frozen %d\n", deliver_frozen_at); +if (deliver_freeze) fprintf(f, "-frozen " TIME_T_FMT "\n", deliver_frozen_at); if (dont_deliver) fprintf(f, "-N\n"); if (host_lookup_deferred) fprintf(f, "-host_lookup_deferred\n"); if (host_lookup_failed) fprintf(f, "-host_lookup_failed\n"); diff --git a/src/src/tod.c b/src/src/tod.c index 427227c68..0297e375e 100644 --- a/src/src/tod.c +++ b/src/src/tod.c @@ -74,8 +74,8 @@ if (type == tod_log) type = log_timezone? tod_log_zone : tod_log_bare; else if (type == tod_epoch) { - (void) sprintf(CS timebuf, "%d", (int)now); /* Unix epoch format */ - return timebuf; + (void) sprintf(CS timebuf, TIME_T_FMT, now); /* Unix epoch format */ + return timebuf; /* NB the above will be wrong if time_t is FP */ } else if (type == tod_zulu) diff --git a/src/src/transports/appendfile.c b/src/src/transports/appendfile.c index db3b5aeee..f56862bec 100644 --- a/src/src/transports/appendfile.c +++ b/src/src/transports/appendfile.c @@ -1620,6 +1620,7 @@ if (!isdirectory) if (ob->use_lockfile) { + /* cf. exim_lock.c */ lockname = string_sprintf("%s.lock", filename); hitchname = string_sprintf( "%s.%s.%08x.%08x", lockname, primary_hostname, (unsigned int)(time(NULL)), (unsigned int)getpid()); |