Nuutti Kotivuori <naked@iki.fi> writes:
> Index: ./subversion/libsvn_subr/time.c
> ===================================================================
[snip]
> apr_time_t
> svn_time_from_nts (const char *data)
> {
It's not part of your current patch, but this function can obviously
fail. I think it should be
svn_error_t *
svn_time_from_nts(apr_time_t *when, const char *data, apr_pool_t *pool)
> @@ -126,26 +111,54 @@
> char wday[4], month[4];
> apr_time_t when;
>
> - sscanf (data,
> - timestamp_format,
> - wday,
> - &exploded_time.tm_mday,
> - month,
> - &exploded_time.tm_year,
> - &exploded_time.tm_hour,
> - &exploded_time.tm_min,
> - &exploded_time.tm_sec,
> - &exploded_time.tm_usec,
> - &exploded_time.tm_yday,
> - &exploded_time.tm_isdst,
> - &exploded_time.tm_gmtoff);
> -
> - exploded_time.tm_year -= 1900;
> - exploded_time.tm_yday -= 1;
> - exploded_time.tm_wday = find_matching_string (wday, apr_day_snames);
> - exploded_time.tm_mon = find_matching_string (month, apr_month_snames);
> -
> - apr_implode_gmt (&when, &exploded_time);
> + /* First try the new timestamp format. */
> + if (sscanf (data,
> + timestamp_format,
> + &exploded_time.tm_year,
> + &exploded_time.tm_mon,
> + &exploded_time.tm_mday,
> + &exploded_time.tm_hour,
> + &exploded_time.tm_min,
> + &exploded_time.tm_sec,
> + &exploded_time.tm_usec) == 7)
> + {
> + exploded_time.tm_year -= 1900;
> + exploded_time.tm_mon -= 1;
> + exploded_time.tm_wday = 0;
> + exploded_time.tm_yday = 0;
> + exploded_time.tm_isdst = 0;
> + exploded_time.tm_gmtoff = 0;
> +
> + apr_implode_gmt (&when, &exploded_time);
> + }
> + /* Then try the compatibility option. */
> + else if (sscanf (data,
> + old_timestamp_format,
> + wday,
> + &exploded_time.tm_mday,
> + month,
> + &exploded_time.tm_year,
> + &exploded_time.tm_hour,
> + &exploded_time.tm_min,
> + &exploded_time.tm_sec,
> + &exploded_time.tm_usec,
> + &exploded_time.tm_yday,
> + &exploded_time.tm_isdst,
> + &exploded_time.tm_gmtoff) == 11)
> + {
> + exploded_time.tm_year -= 1900;
> + exploded_time.tm_yday -= 1;
> + exploded_time.tm_wday = find_matching_string (wday, apr_day_snames);
> + exploded_time.tm_mon = find_matching_string (month, apr_month_snames);
> +
> + apr_implode_gmt (&when, &exploded_time);
> + }
> + /* Timestamp is something we do not recognize. */
> + else
> + {
> + /* Better zero than something random. */
> + when = 0;
Then we could return an error here, instead of silently ignoring the
problem.
> + }
>
> return when;
> }
--
Philip
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue May 14 01:37:38 2002