]> granicus.if.org Git - php/commitdiff
prevent segv on Windows with negative localtime values.
authorIlia Alshanetsky <iliaa@php.net>
Wed, 25 Sep 2002 12:20:56 +0000 (12:20 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 25 Sep 2002 12:20:56 +0000 (12:20 +0000)
ext/standard/datetime.c

index 5dc2b5d259ad78678e98a7f03017835730244ca2..386236a73cf078e432134612759d910716b8f802 100644 (file)
@@ -194,9 +194,13 @@ void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gm)
        } 
        
        t = mktime(ta); 
-       if (t == -1) {
+
+#ifdef PHP_WIN32
+       if (t < 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Windows does not support negative values for this function");
                RETURN_LONG(-1);
        }
+#endif
 
        seconds = t - chgsecs;
 
@@ -646,7 +650,15 @@ PHP_FUNCTION(localtime)
                        assoc_array = Z_LVAL_PP(assoc_array_arg);
                        break;
        }
-       if (timestamp < 0 || NULL == (ta = php_localtime_r(&timestamp, &tmbuf))) {
+       
+#ifdef PHP_WIN32
+       if (timestamp < 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Windows does not support negative values for this function");
+               RETURN_FALSE
+       }
+#endif
+       
+       if (NULL == (ta = php_localtime_r(&timestamp, &tmbuf))) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid local time");
                RETURN_FALSE;
        }