summaryrefslogtreecommitdiff
path: root/ext/standard/datetime.c
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2002-09-25 12:20:56 +0000
committerIlia Alshanetsky <iliaa@php.net>2002-09-25 12:20:56 +0000
commit322a24a5262743a8e7c904b7a8c435be17a17160 (patch)
tree91dc4e0297a16a2e1781c43eec817e152abd454f /ext/standard/datetime.c
parentc57d41992589c315d9db3338cd3f50caa47806db (diff)
downloadphp-git-322a24a5262743a8e7c904b7a8c435be17a17160.tar.gz
prevent segv on Windows with negative localtime values.
Diffstat (limited to 'ext/standard/datetime.c')
-rw-r--r--ext/standard/datetime.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/standard/datetime.c b/ext/standard/datetime.c
index 5dc2b5d259..386236a73c 100644
--- a/ext/standard/datetime.c
+++ b/ext/standard/datetime.c
@@ -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;
}