Commit f959bee0 authored by Thomas Roessler's avatar Thomas Roessler

mutt_parse_date () shouldn't modify its argument. Problem noted by

Byrial Jensen.
parent cde06330
......@@ -1231,14 +1231,8 @@ static void external_body_handler (BODY *b, STATE *s)
}
expiration = mutt_get_parameter ("expiration", b->parameter);
if (expiration)
{
/* mutt_parse_date() will alter its argument, so we need a copy */
char *e = safe_strdup (expiration);
expire = mutt_parse_date (e, NULL);
free (e);
}
if (expiration)
expire = mutt_parse_date (expiration, NULL);
else
expire = -1;
......
......@@ -660,7 +660,7 @@ TimeZones[] =
* This routine assumes that `h' has been initialized to 0. the `timezone'
* field is optional, defaulting to +0000 if missing.
*/
time_t mutt_parse_date (char *s, HEADER *h)
time_t mutt_parse_date (const char *s, HEADER *h)
{
int count = 0;
char *t;
......@@ -673,12 +673,19 @@ time_t mutt_parse_date (char *s, HEADER *h)
int zoccident = 0;
const char *ptz;
char tzstr[SHORT_STRING];
char scratch[SHORT_STRING];
/* Don't modify our argument. Fixed-size buffer is ok here since
* the date format imposes a natural limit.
*/
strfcpy (scratch, s, sizeof (scratch));
/* kill the day of the week, if it exists. */
if ((t = strchr (s, ',')))
if ((t = strchr (scratch, ',')))
t++;
else
t = s;
t = scratch;
SKIPWS (t);
memset (&tm, 0, sizeof (tm));
......
......@@ -97,7 +97,7 @@ ATTACHPTR **mutt_gen_attach_list (BODY *, int, ATTACHPTR **, short *, short *, i
time_t mutt_local_tz (void);
time_t mutt_mktime (struct tm *, int);
time_t is_from (const char *, char *, size_t);
time_t mutt_parse_date (char *, HEADER *);
time_t mutt_parse_date (const char *, HEADER *);
const char *mutt_attach_fmt (
char *dest,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment