aboutsummaryrefslogtreecommitdiff
path: root/php
diff options
context:
space:
mode:
authorDavid Supplee <dwsupplee@gmail.com>2019-03-12 21:30:06 -0700
committerPaul Yang <TeBoring@users.noreply.github.com>2019-03-12 21:30:06 -0700
commit93533f780be4ed5ea4d866c5eb7ff2220f377ae0 (patch)
treee6ceff1770a8455af7dfc2eeebcda0730a9ffc2e /php
parent791b86368778e21fd4936f0f8674daff44046dff (diff)
downloadprotobuf-93533f780be4ed5ea4d866c5eb7ff2220f377ae0.tar.gz
Add terminating character to zend_lookup_class call (#5871)
* add terminating character * adjust name length input * add test cases * correct script name * Misc fixes * add new script to EXTRA_DIST list
Diffstat (limited to 'php')
-rw-r--r--php/ext/google/protobuf/def.c3
-rwxr-xr-xphp/tests/compile_extension.sh10
-rw-r--r--php/tests/php_implementation_test.php11
-rwxr-xr-xphp/tests/test.sh7
4 files changed, 24 insertions, 7 deletions
diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c
index ef0f71167..184ae2d36 100644
--- a/php/ext/google/protobuf/def.c
+++ b/php/ext/google/protobuf/def.c
@@ -853,9 +853,10 @@ static zend_class_entry *register_class(const upb_filedef *file,
fill_namespace(package, php_namespace, &namesink);
fill_classname(fullname, package, prefix, &namesink, use_nested_submsg);
+ stringsink_string(&namesink, NULL, "\0", 1, NULL);
PHP_PROTO_CE_DECLARE pce;
- if (php_proto_zend_lookup_class(namesink.ptr, namesink.len, &pce) ==
+ if (php_proto_zend_lookup_class(namesink.ptr, namesink.len - 1, &pce) ==
FAILURE) {
zend_error(
E_ERROR,
diff --git a/php/tests/compile_extension.sh b/php/tests/compile_extension.sh
new file mode 100755
index 000000000..bbd669684
--- /dev/null
+++ b/php/tests/compile_extension.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+EXTENSION_PATH=$1
+
+pushd $EXTENSION_PATH
+make clean || true
+set -e
+# Add following in configure for debug: --enable-debug CFLAGS='-g -O0'
+phpize && ./configure CFLAGS='-g -O0' && make
+popd
diff --git a/php/tests/php_implementation_test.php b/php/tests/php_implementation_test.php
index 8d27d19f0..307b749c4 100644
--- a/php/tests/php_implementation_test.php
+++ b/php/tests/php_implementation_test.php
@@ -14,8 +14,19 @@ use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\GPBWire;
use Google\Protobuf\Internal\CodedOutputStream;
+/**
+ * Please note, this test is only intended to be run without the protobuf C
+ * extension.
+ */
class ImplementationTest extends TestBase
{
+ public function setUp()
+ {
+ if (extension_loaded('protobuf')) {
+ $this->markTestSkipped();
+ }
+ }
+
public function testReadInt32()
{
$value = null;
diff --git a/php/tests/test.sh b/php/tests/test.sh
index b5e8769e5..be6e97fe8 100755
--- a/php/tests/test.sh
+++ b/php/tests/test.sh
@@ -7,12 +7,7 @@ export C_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$V
export CPLUS_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$VERSION/include/php:$CPLUS_INCLUDE_PATH
# Compile c extension
-pushd ../ext/google/protobuf/
-make clean || true
-set -e
-# Add following in configure for debug: --enable-debug CFLAGS='-g -O0'
-phpize && ./configure CFLAGS='-g -O0' && make
-popd
+/bin/bash ./compile_extension.sh ../ext/google/protobuf
tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php descriptors_test.php wrapper_type_setters_test.php)