bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mktime() and invalid dates


From: Aharon Robbins
Subject: Re: mktime() and invalid dates
Date: Tue, 27 Apr 2010 22:22:26 +0300
User-agent: Heirloom mailx 12.4 7/29/08

Thanks for the patch. I'll get this and the redundant minute check
fixed.  Too much late-night programming.

Arnold

> From: Andreas Schwab <address@hidden>
> To: Aharon Robbins <address@hidden>
> Cc: address@hidden, address@hidden
> Subject: Re: mktime() and invalid dates
> Date: Tue, 27 Apr 2010 15:44:48 +0200
>
> Aharon Robbins <address@hidden> writes:
>
> > Thanks to everyone for pointing out that I had documented that this is
> > a feature. I've restored the original code in my code base. CVS will be
> > reflecting things soon.
>
> GCC warnings are never stupid.  You cannot check for overflow after the
> fact.
>
> And days and months start with one, normally.
>
> Andreas.
>
> --- builtin.c.~1.43.~ 2010-04-27 15:10:57.000000000 +0200
> +++ builtin.c 2010-04-27 15:27:56.000000000 +0200
> @@ -1742,17 +1742,17 @@ do_mktime(NODE *tree)
>               || (minute < 0 || minute > 50)
>               || (minute < 0 || minute > 60)
>               || (hour < 0 || hour > 23)
> -             || (day < 0 || day > 31)
> -             || (month < 0 || month > 11) ))
> +             || (day < 1 || day > 31)
> +             || (month < 1 || month > 12) ))
>               lintwarn(_("mktime: at least one of the values is out of the 
> default range"));
>  
>       t1->stptr[t1->stlen] = save;
>       free_temp(t1);
>  
>       if (count < 6
> -         || month < month - 1
> -         || year < year - 1900
> -         || year - 1900 != (int) (year - 1900))
> +         || month == INT_MIN
> +         || year < INT_MIN + 1900
> +         || year - 1900 > INT_MAX)
>               return tmp_number((AWKNUM) -1);
>  
>       memset(& then, '\0', sizeof(then));
>
> -- 
> Andreas Schwab, address@hidden
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]