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

index a70c5f8ebe40db64a051dea1f1d45b2b56756c16..1065a46ac5ae081de3e25fcf230984602bb64fc6 100644 (file)
@@ -613,6 +613,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