From: Stanislav Malyshev Date: Sun, 10 Sep 2000 13:34:03 +0000 (+0000) Subject: Fix pack() function reading string beyond the end X-Git-Tag: php-4.0.3RC1~204 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4237ddadb5d56970d405c7329890b76568f6e390;p=php Fix pack() function reading string beyond the end --- diff --git a/ext/standard/pack.c b/ext/standard/pack.c index 8e3a32d115..7afe52a6af 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -302,6 +302,10 @@ PHP_FUNCTION(pack) convert_to_string_ex(val); v = (*val)->value.str.val; outputpos--; + if(arg > (*val)->value.str.len) { + php_error(E_WARNING,"pack type %c: not enough characters in string",code); + arg = (*val)->value.str.len; + } while (arg-- > 0) { char n = *(v++);