]> granicus.if.org Git - php/commitdiff
Fix pack() function reading string beyond the end
authorStanislav Malyshev <stas@php.net>
Sun, 10 Sep 2000 13:34:03 +0000 (13:34 +0000)
committerStanislav Malyshev <stas@php.net>
Sun, 10 Sep 2000 13:34:03 +0000 (13:34 +0000)
ext/standard/pack.c

index 8e3a32d1154028db1adfa7d5c81a6c2ba8f8c63f..7afe52a6af6244ec5a953baa9917cc40567a2e40 100644 (file)
@@ -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++);