]> granicus.if.org Git - php/commitdiff
protect datetime() against all zero inputs ...
authorHartmut Holzgraefe <hholzgra@php.net>
Tue, 1 Aug 2000 11:16:20 +0000 (11:16 +0000)
committerHartmut Holzgraefe <hholzgra@php.net>
Tue, 1 Aug 2000 11:16:20 +0000 (11:16 +0000)
ext/standard/datetime.c

index 2c4622ac0b7319538e3b2c99964710b33bfd76a5..61416c0dd67ed2dcc85a4041e58e8f7a34ebb72b 100644 (file)
@@ -120,6 +120,17 @@ void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gm)
                ta->tm_isdst = is_dst = (*arguments[6])->value.lval;
                /* fall-through */
        case 6:
+               /* special case: 
+                  a zero in year, month and day is considered illegal
+                  as it would be interpreted as 30.11.1999 otherwise
+               */
+               if (  (  (*arguments[5])->value.lval==0)
+                         &&((*arguments[4])->value.lval==0)
+                         &&((*arguments[3])->value.lval==0)
+                         ) {
+                       RETURN_LONG(-1);
+               }
+
                /*
                ** Accept parameter in range 0..1000 interpreted as 1900..2900
                ** (if 100 is given, it means year 2000)