From 0b70f9e88468e2b9a076cb8cf33e023e7d4f62ec Mon Sep 17 00:00:00 2001 From: "Preston L. Bannister" Date: Thu, 16 May 2002 12:31:05 +0000 Subject: [PATCH] Range check arguments to mb_strcut(). Test ext/mbstring/013.phpt causes a hard failure w/o this. --- ext/mbstring/mbstring.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index f5c1e02ebb..782474f403 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -2059,6 +2059,10 @@ PHP_FUNCTION(mb_strcut) if (from < 0) { from = 0; } + } + if (Z_STRLEN_PP(arg1) < from) { + /* keep index within string */ + from = Z_STRLEN_PP(arg1); } /* if "length" position is negative, set it to the length @@ -2070,6 +2074,10 @@ PHP_FUNCTION(mb_strcut) len = 0; } } + if (Z_STRLEN_PP(arg1) < (from + len)) { + /* limit span to characters in string */ + len = Z_STRLEN_PP(arg1) - from; + } ret = mbfl_strcut(&string, &result, from, len TSRMLS_CC); if (ret != NULL) { -- 2.50.1