diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2003-06-02 09:12:22 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2003-06-02 09:12:22 +0000 |
commit | 3da52798917b92b79751c7eb9a0c1b721f167318 (patch) | |
tree | 18438f315e96e620210517ebe8ce738e084264c6 | |
parent | beea97a599a671dee7c8ab4cf20d5752025ff247 (diff) | |
download | mailutils-3da52798917b92b79751c7eb9a0c1b721f167318.tar.gz mailutils-3da52798917b92b79751c7eb9a0c1b721f167318.tar.bz2 |
(fetch_internaldate): Bugfix. Coredumped on invalid dates.
-rw-r--r-- | imap4d/fetch.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/imap4d/fetch.c b/imap4d/fetch.c index a1478317f..64b9de09b 100644 --- a/imap4d/fetch.c +++ b/imap4d/fetch.c @@ -337,17 +337,25 @@ fetch_flags (struct fetch_command *command, char **arg) static int fetch_internaldate (struct fetch_command *command, char **arg ARG_UNUSED) { - char date[128], *p; + char date[128]; envelope_t env = NULL; - struct tm tm; + struct tm tm, *tmp = NULL; mu_timezone tz; message_get_envelope (command->msg, &env); date[0] = '\0'; - envelope_date (env, date, sizeof (date), NULL); - p = date; - mu_parse_ctime_date_time ((const char **) &p, &tm, &tz); - strftime (date, sizeof (date), "%d-%b-%Y %H:%M:%S", &tm); + if (envelope_date (env, date, sizeof (date), NULL) == 0) + { + char *p = date; + if (mu_parse_ctime_date_time ((const char **) &p, &tm, &tz) == 0) + tmp = &tm; + } + if (!tmp) + { + time_t t = time(NULL); + tmp = localtime(&t); + } + strftime (date, sizeof (date), "%d-%b-%Y %H:%M:%S", tmp); util_send ("%s", command->name); util_send (" \"%s +0000\"", date); return RESP_OK; |