[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mktime() and invalid dates
From: |
Andreas Schwab |
Subject: |
Re: mktime() and invalid dates |
Date: |
Tue, 27 Apr 2010 15:44:48 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.96 (gnu/linux) |
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."