]> granicus.if.org Git - php/commitdiff
Added missing format validator to unpack() function
authorIlia Alshanetsky <iliaa@php.net>
Wed, 6 Jun 2007 22:04:05 +0000 (22:04 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 6 Jun 2007 22:04:05 +0000 (22:04 +0000)
NEWS
ext/standard/pack.c
ext/standard/tests/strings/unpack.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 278fdd153ef4e2881e4cc595d546a4916ecb77e4..e74192367c80beaad9dc0971f4c7fea4086a3499 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ PHP                                                                        NEWS
 - Fixed size calculation in chunk_split() (Stas)
 - Fixed integer overlow in str[c]spn() (Stas)
 - Fixed UMR in money_format() (Stas, Ilia)
+- Added missing format validator to unpack() function (Ilia)
 - Fixed PECL bug #11216 (crash in ZipArchive::addEmptyDir when a directory 
   already exists). (Pierre)
 - Fixed bug #41608 (segfault on a weird code with objects and switch()). 
index 15924dba043485993c85491e9a5c559f8666cdce..1e7acac6e12975513e1ac167ce3473bdbefc06e7 100644 (file)
@@ -635,6 +635,12 @@ PHP_FUNCTION(unpack)
                        case 'd':
                                size = sizeof(double);
                                break;
+
+                       default:
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid format type %c", type);
+                               zval_dtor(return_value);
+                               RETURN_FALSE;
+                               break;
                }
 
                /* Do actual unpacking */
diff --git a/ext/standard/tests/strings/unpack.phpt b/ext/standard/tests/strings/unpack.phpt
new file mode 100644 (file)
index 0000000..f843dab
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Invalid format type validation
+--FILE--
+<?php
+       var_dump(unpack("-2222", 1));
+       echo "Done\n";
+?>
+--EXPECTF--
+Warning: unpack(): Invalid format type - in %s/unpack.php on line %d
+bool(false)
+Done
\ No newline at end of file