php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | |
Patch 0003-improve-loop-condition-to-avoid-hang-on-large-value.patch for Unknown/Other Function Bug #70112Patch version 2015-07-24 08:39 UTC Return to Bug #70112 | Download this patchThis patch is obsolete Obsoleted by patches: Patch Revisions:Developer: remi@php.netFrom 9f069d39534fdab94ccc71c4a58cdc8b3056bdc8 Mon Sep 17 00:00:00 2001 From: Remi Collet <fedora@famillecollet.com> Date: Fri, 24 Jul 2015 10:37:59 +0200 Subject: [PATCH 3/3] improve loop condition to avoid hang on large value --- ext/standard/string.c | 4 ++-- ext/standard/tests/strings/dirname_multi.phpt | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/standard/string.c b/ext/standard/string.c index d921ad0..f71e6da 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1666,8 +1666,8 @@ PHP_FUNCTION(dirname) } ret = zend_string_init(str, str_len, 0); do { - ZSTR_LEN(ret) = zend_dirname(ZSTR_VAL(ret), ZSTR_LEN(ret)); - } while (ZSTR_LEN(ret) && --levels>0); + ZSTR_LEN(ret) = zend_dirname(ZSTR_VAL(ret), str_len=ZSTR_LEN(ret)); + } while (ZSTR_LEN(ret)<str_len && --levels>0); RETURN_NEW_STR(ret); } diff --git a/ext/standard/tests/strings/dirname_multi.phpt b/ext/standard/tests/strings/dirname_multi.phpt index 113dd3c..d0fdfac 100644 --- a/ext/standard/tests/strings/dirname_multi.phpt +++ b/ext/standard/tests/strings/dirname_multi.phpt @@ -8,6 +8,7 @@ Test dirname() function : usage variations for ($i=1 ; $i<5 ; $i++) { var_dump(dirname("/foo/bar/baz", $i)); } +var_dump(dirname("/foo/bar/baz", PHP_INT_MAX)); ?> Done --EXPECT-- @@ -15,4 +16,5 @@ string(8) "/foo/bar" string(4) "/foo" string(1) "/" string(1) "/" +string(1) "/" Done -- 2.1.0 |
Copyright © 2001-2024 The PHP Group All rights reserved. |
Last updated: Thu Oct 10 10:01:27 2024 UTC |