You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Stas Bekman <st...@stason.org> on 2003/09/02 23:10:19 UTC
Re: [patch: srclib/apr-util/misc/apr_date.c] fix datastring corruption
This is another patch that resulted from
http://marc.theaimsgroup.com/?l=apr-dev&m=101223985500849&w=2
but was never commented on/committed
Stas Bekman wrote:
> this patch makes sure that apr_date_parse_rfc doesn't corrupt the
> callers date string.
>
> it was discussed in this thread:
> http://marc.theaimsgroup.com/?l=apr-dev&m=101223985500849&w=2
>
>
> Index: srclib/apr-util/misc/apr_date.c
> ===================================================================
> RCS file: /home/cvspublic/apr-util/misc/apr_date.c,v
> retrieving revision 1.10
> diff -u -r1.10 apr_date.c
> --- srclib/apr-util/misc/apr_date.c 13 Mar 2002 20:40:49 -0000 1.10
> +++ srclib/apr-util/misc/apr_date.c 14 Mar 2002 03:23:43 -0000
> @@ -349,6 +349,7 @@
> apr_time_t result;
> int mint, mon;
> char *monstr, *timstr, *gmtstr;
> + char dummy[8];
> static const int months[12] =
> {
> ('J' << 16) | ('a' << 8) | 'n', ('F' << 16) | ('e' << 8) | 'b',
> @@ -473,7 +474,9 @@
> ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0');
>
> monstr = date + 3;
> - timstr = date + 10;
> + strncpy(dummy, date + 10, 8);
> + timstr = dummy;
> +
> timstr[6] = '0';
> timstr[7] = '0';
> gmtstr = NULL;
> @@ -488,7 +491,8 @@
> ds.tm_mday = (date[0] - '0');
>
> monstr = date + 2;
> - timstr = date + 9;
> + strncpy(dummy, date + 9, 8);
> + timstr = dummy;
>
> timstr[6] = '0';
> timstr[7] = '0';
> @@ -504,7 +508,8 @@
> ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0');
>
> monstr = date + 3;
> - timstr = date + 9;
> + strncpy(dummy, date + 9, 8);
> + timstr = dummy;
>
> timstr[0] = '0';
> gmtstr = date + 18;
> @@ -519,7 +524,8 @@
> ds.tm_mday = (date[0] - '0');
>
> monstr = date + 2;
> - timstr = date + 8;
> + strncpy(dummy, date + 8, 8);
> + timstr = dummy;
>
> timstr[0] = '0';
> gmtstr = date + 17;
>
>
>
> _____________________________________________________________________
> Stas Bekman JAm_pH -- Just Another mod_perl Hacker
> http://stason.org/ mod_perl Guide http://perl.apache.org/guide
> mailto:stas@stason.org http://ticketmaster.com http://apacheweek.com
> http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com