sixd                                     Thu, 29 Apr 2010 05:07:16 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=298755

Log:
Bug #51691 (Unnecessary realloc causes crashes in PHP trunk tests with interned 
strings).  Updated tests check some other edge cases

Bug: http://bugs.php.net/51691 (Assigned) Unnecessary realloc causes crash with 
"interned" strings
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/oci8/oci8_statement.c
    U   php/php-src/branches/PHP_5_3/ext/oci8/package.xml
    U   php/php-src/branches/PHP_5_3/ext/oci8/tests/bind_empty.phpt
    U   php/php-src/trunk/ext/oci8/oci8_statement.c
    U   php/php-src/trunk/ext/oci8/tests/bind_empty.phpt

Modified: php/php-src/branches/PHP_5_3/ext/oci8/oci8_statement.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/oci8/oci8_statement.c	2010-04-29 05:07:03 UTC (rev 298754)
+++ php/php-src/branches/PHP_5_3/ext/oci8/oci8_statement.c	2010-04-29 05:07:16 UTC (rev 298755)
@@ -880,7 +880,15 @@
 		}
 		zval_dtor(val);
 		ZVAL_NULL(val);
-	} else if (Z_TYPE_P(bind->zval) == IS_STRING && Z_STRLEN_P(bind->zval) > 0) {
+	} else if (Z_TYPE_P(bind->zval) == IS_STRING
+			   && Z_STRLEN_P(bind->zval) > 0
+			   && Z_STRVAL_P(bind->zval)[ Z_STRLEN_P(bind->zval) ] != '\0') {
+		/* The post- PHP 5.3 feature for "interned" strings disallows
+		 * their reallocation but (i) any IN binds either interned or
+		 * not should already be null terminated and (ii) for OUT
+		 * binds, php_oci_bind_out_callback() should have allocated a
+		 * new string that can be realloced.
+		 */
 		Z_STRVAL_P(bind->zval) = erealloc(Z_STRVAL_P(bind->zval), Z_STRLEN_P(bind->zval)+1);
 		Z_STRVAL_P(bind->zval)[ Z_STRLEN_P(bind->zval) ] = '\0';
 	} else if (Z_TYPE_P(bind->zval) == IS_ARRAY) {

Modified: php/php-src/branches/PHP_5_3/ext/oci8/package.xml
===================================================================
--- php/php-src/branches/PHP_5_3/ext/oci8/package.xml	2010-04-29 05:07:03 UTC (rev 298754)
+++ php/php-src/branches/PHP_5_3/ext/oci8/package.xml	2010-04-29 05:07:16 UTC (rev 298755)
@@ -33,7 +33,7 @@
   <active>no</active>
  </lead>

- <date>2010-02-11</date>
+ <date>2010-03-30</date>
  <time>15:00:00</time>

  <version>
@@ -41,12 +41,14 @@
   <api>1.4.2</api>
  </version>
  <stability>
-  <release>development</release>
-  <api>development</api>
+  <release>devel</release>
+  <api>devel</api>
  </stability>
  <license uri="http://www.php.net/license";>PHP</license>
  <notes>
+    Fixed Bug #51691 (Unnecessary realloc causes crashes in PHP trunk tests with interned strings)
     Fixed bug #51291 (oci_error doesn't report last error when called two times)
+    Fixed Bug #51577 (Uninitialized memory reference with oci_bind_array_by_name)
  </notes>
  <contents>
   <dir name="/">
@@ -76,20 +78,38 @@
     <file name="b47243_1.phpt" role="test" />
     <file name="b47243_2.phpt" role="test" />
     <file name="b47243_3.phpt" role="test" />
+    <file name="bind_char_1_11gR1.phpt" role="test" />
     <file name="bind_char_1.phpt" role="test" />
+    <file name="bind_char_2_11gR1.phpt" role="test" />
     <file name="bind_char_2.phpt" role="test" />
+    <file name="bind_char_3_11gR1.phpt" role="test" />
     <file name="bind_char_3.phpt" role="test" />
+    <file name="bind_char_4_11gR1.phpt" role="test" />
     <file name="bind_char_4.phpt" role="test" />
     <file name="bind_empty.phpt" role="test" />
-    <file name="bind_error.phpt" role="test" />
     <file name="bind_long.phpt" role="test" />
     <file name="bind_long_raw.phpt" role="test" />
+    <file name="bind_misccoltypes_errs.phpt" role="test" />
+    <file name="bind_misccoltypes.phpt" role="test" />
+    <file name="bind_number.phpt" role="test" />
+    <file name="bind_query.phpt" role="test" />
     <file name="bind_raw.phpt" role="test" />
+    <file name="bind_rowid.phpt" role="test" />
+    <file name="bind_sqltafc.phpt" role="test" />
+    <file name="bind_sqltchr.phpt" role="test" />
+    <file name="bind_sqltint.phpt" role="test" />
+    <file name="bind_sqltnum.phpt" role="test" />
+    <file name="bind_unsupported_1.phpt" role="test" />
+    <file name="bind_unsupported_2.phpt" role="test" />
+    <file name="bind_unsupported_3.phpt" role="test" />
     <file name="bug26133.phpt" role="test" />
+    <file name="bug27303_1_11gR1.phpt" role="test" />
+    <file name="bug27303_1.phpt" role="test" />
+    <file name="bug27303_2_11gR1.phpt" role="test" />
     <file name="bug27303_2.phpt" role="test" />
     <file name="bug27303_3.phpt" role="test" />
+    <file name="bug27303_4_11gR1.phpt" role="test" />
     <file name="bug27303_4.phpt" role="test" />
-    <file name="bug27303.phpt" role="test" />
     <file name="bug32325.phpt" role="test" />
     <file name="bug35973.phpt" role="test" />
     <file name="bug36010.phpt" role="test" />
@@ -118,7 +138,8 @@
     <file name="bug46994.phpt" role="test" />
     <file name="bug47189.phpt" role="test" />
     <file name="bug47281.phpt" role="test" />
-    <file name="bug6109.phpt" role="test" />
+    <file name="bug51253.phpt" role="test" />
+    <file name="bug51291.phpt" role="test" />
     <file name="close.phpt" role="test" />
     <file name="coll_001.phpt" role="test" />
     <file name="coll_002_func.phpt" role="test" />
@@ -152,8 +173,9 @@
     <file name="coll_017.phpt" role="test" />
     <file name="coll_018.phpt" role="test" />
     <file name="coll_019.phpt" role="test" />
+    <file name="commit_001.phpt" role="test" />
+    <file name="commit_002.phpt" role="test" />
     <file name="commit_old.phpt" role="test" />
-    <file name="commit.phpt" role="test" />
     <file name="conn_attr_1.phpt" role="test" />
     <file name="conn_attr_2.phpt" role="test" />
     <file name="conn_attr_3.phpt" role="test" />
@@ -182,17 +204,22 @@
     <file name="cursor_bind.phpt" role="test" />
     <file name="cursors_old.phpt" role="test" />
     <file name="cursors.phpt" role="test" />
+    <file name="dbmsoutput.phpt" role="test" />
     <file name="debug.phpt" role="test" />
+    <file name="default_prefetch0.phpt" role="test" />
     <file name="default_prefetch1.phpt" role="test" />
     <file name="default_prefetch2.phpt" role="test" />
     <file name="default_prefetch.phpt" role="test" />
+    <file name="define0.phpt" role="test" />
     <file name="define1.phpt" role="test" />
     <file name="define2.phpt" role="test" />
     <file name="define3.phpt" role="test" />
     <file name="define4.phpt" role="test" />
     <file name="define5.phpt" role="test" />
+    <file name="define6.phpt" role="test" />
     <file name="define_old.phpt" role="test" />
     <file name="define.phpt" role="test" />
+    <file name="define_rowid.phpt" role="test" />
     <file name="descriptors.phpt" role="test" />
     <file name="details.inc" role="test" />
     <file name="drcp_cclass1.phpt" role="test" />
@@ -214,11 +241,14 @@
     <file name="driver_name.phpt" role="test" />
     <file name="drop_table.inc" role="test" />
     <file name="drop_type.inc" role="test" />
+    <file name="dupcolnames.phpt" role="test" />
     <file name="edition_1.phpt" role="test" />
     <file name="edition_2.phpt" role="test" />
     <file name="error1.phpt" role="test" />
     <file name="error2.phpt" role="test" />
+    <file name="error_bind.phpt" role="test" />
     <file name="error_old.phpt" role="test" />
+    <file name="error_parse.phpt" role="test" />
     <file name="error.phpt" role="test" />
     <file name="exec_fetch.phpt" role="test" />
     <file name="execute_mode.phpt" role="test" />
@@ -226,6 +256,7 @@
     <file name="extauth_02.phpt" role="test" />
     <file name="extauth_03.phpt" role="test" />
     <file name="extauth_04.phpt" role="test" />
+    <file name="fetch_all1.phpt" role="test" />
     <file name="fetch_all2.phpt" role="test" />
     <file name="fetch_all3.phpt" role="test" />
     <file name="fetch_all4.phpt" role="test" />
@@ -236,12 +267,15 @@
     <file name="fetch_into1.phpt" role="test" />
     <file name="fetch_into2.phpt" role="test" />
     <file name="fetch_into.phpt" role="test" />
+    <file name="fetch_object_1.phpt" role="test" />
     <file name="fetch_object_2.phpt" role="test" />
     <file name="fetch_object.phpt" role="test" />
     <file name="fetch.phpt" role="test" />
     <file name="fetch_row.phpt" role="test" />
+    <file name="field_funcs0.phpt" role="test" />
     <file name="field_funcs1.phpt" role="test" />
     <file name="field_funcs2.phpt" role="test" />
+    <file name="field_funcs3.phpt" role="test" />
     <file name="field_funcs_old.phpt" role="test" />
     <file name="field_funcs.phpt" role="test" />
     <file name="function_aliases.phpt" role="test" />
@@ -299,7 +333,6 @@
     <file name="oci_execute_segfault.phpt" role="test" />
     <file name="old_oci_close1.phpt" role="test" />
     <file name="old_oci_close.phpt" role="test" />
-    <file name="parse_error.phpt" role="test" />
     <file name="password_2.phpt" role="test" />
     <file name="password_new.phpt" role="test" />
     <file name="password_old.phpt" role="test" />
@@ -309,6 +342,7 @@
     <file name="pecl_bug10194.phpt" role="test" />
     <file name="pecl_bug16035.phpt" role="test" />
     <file name="pecl_bug16842.phpt" role="test" />
+    <file name="pecl_bug6109.phpt" role="test" />
     <file name="pecl_bug8816.phpt" role="test" />
     <file name="persistent.phpt" role="test" />
     <file name="prefetch_old.phpt" role="test" />
@@ -320,7 +354,6 @@
     <file name="refcur_prefetch_3.phpt" role="test" />
     <file name="reflection1.phpt" role="test" />
     <file name="reflection2.phpt" role="test" />
-    <file name="rowid_bind.phpt" role="test" />
     <file name="select_null.phpt" role="test" />
     <file name="serverversion.phpt" role="test" />
     <file name="skipif.inc" role="test" />

Modified: php/php-src/branches/PHP_5_3/ext/oci8/tests/bind_empty.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/oci8/tests/bind_empty.phpt	2010-04-29 05:07:03 UTC (rev 298754)
+++ php/php-src/branches/PHP_5_3/ext/oci8/tests/bind_empty.phpt	2010-04-29 05:07:16 UTC (rev 298755)
@@ -7,11 +7,11 @@

 require dirname(__FILE__).'/connect.inc';

-$drop = "DROP table bind_test";
+$drop = "DROP table bind_empty_tab";
 $statement = oci_parse($c, $drop);
 @oci_execute($statement);

-$create = "CREATE table bind_test(name VARCHAR(10))";
+$create = "CREATE table bind_empty_tab(name VARCHAR(10))";
 $statement = oci_parse($c, $create);
 oci_execute($statement);

@@ -19,7 +19,7 @@
 echo "Test 1\n";

 $name = null;
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name");
 oci_bind_by_name($stmt, ":name", $name);

 var_dump(oci_execute($stmt));
@@ -27,26 +27,26 @@
 echo "Test 2\n";

 $name = "";
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name");
 oci_bind_by_name($stmt, ":name", $name);

 var_dump(oci_execute($stmt));

 echo "Test 3\n";

-$stmt = oci_parse($c, "INSERT INTO bind_test (NAME) VALUES ('abc')");
+$stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('abc')");
 $res = oci_execute($stmt);

-$stmt = oci_parse($c, "INSERT INTO bind_test (NAME) VALUES ('def')");
+$stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('def')");
 $res = oci_execute($stmt);

 $name = null;
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name WHERE NAME = 'abc'");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name WHERE NAME = 'abc'");
 oci_bind_by_name($stmt, ":name", $name);

 var_dump(oci_execute($stmt));

-$stid = oci_parse($c, "select * from bind_test order by 1");
+$stid = oci_parse($c, "select * from bind_empty_tab order by 1");
 oci_execute($stid);
 oci_fetch_all($stid, $res);
 var_dump($res);
@@ -54,26 +54,43 @@
 echo "Test 4\n";

 $name = "";
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name WHERE NAME = 'def'");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name WHERE NAME = 'def'");
 oci_bind_by_name($stmt, ":name", $name);

 var_dump(oci_execute($stmt));

-$stid = oci_parse($c, "select * from bind_test order by 1");
+$stid = oci_parse($c, "select * from bind_empty_tab order by 1");
 oci_execute($stid);
 oci_fetch_all($stid, $res);
 var_dump($res);

+echo "Test 5\n";

+$av = $bv = 'old';
+$s = oci_parse($c, "begin :bv := null; end; ");
+oci_bind_by_name($s, ":bv", $bv);
+oci_execute($s);
+var_dump($av);
+var_dump($bv);
+
+echo "Test 6\n";
+
+$av = $bv = null;
+$s = oci_parse($c, "begin :bv := null; end; ");
+oci_bind_by_name($s, ":bv", $bv);
+oci_execute($s);
+var_dump($av);
+var_dump($bv);
+
 // Clean up

-$drop = "DROP table bind_test";
+$drop = "DROP table bind_empty_tab";
 $statement = oci_parse($c, $drop);
 @oci_execute($statement);

-echo "Done\n";
-
 ?>
+===DONE===
+<?php exit(0); ?>
 --EXPECTF--
 Test 1
 bool(true)
@@ -101,4 +118,10 @@
     NULL
   }
 }
-Done
+Test 5
+string(3) "old"
+NULL
+Test 6
+NULL
+NULL
+===DONE===

Modified: php/php-src/trunk/ext/oci8/oci8_statement.c
===================================================================
--- php/php-src/trunk/ext/oci8/oci8_statement.c	2010-04-29 05:07:03 UTC (rev 298754)
+++ php/php-src/trunk/ext/oci8/oci8_statement.c	2010-04-29 05:07:16 UTC (rev 298755)
@@ -880,7 +880,15 @@
 		}
 		zval_dtor(val);
 		ZVAL_NULL(val);
-	} else if (Z_TYPE_P(bind->zval) == IS_STRING && Z_STRLEN_P(bind->zval) > 0) {
+	} else if (Z_TYPE_P(bind->zval) == IS_STRING
+			   && Z_STRLEN_P(bind->zval) > 0
+			   && Z_STRVAL_P(bind->zval)[ Z_STRLEN_P(bind->zval) ] != '\0') {
+		/* The post- PHP 5.3 feature for "interned" strings disallows
+		 * their reallocation but (i) any IN binds either interned or
+		 * not should already be null terminated and (ii) for OUT
+		 * binds, php_oci_bind_out_callback() should have allocated a
+		 * new string that we can modify here.
+		 */
 		Z_STRVAL_P(bind->zval) = erealloc(Z_STRVAL_P(bind->zval), Z_STRLEN_P(bind->zval)+1);
 		Z_STRVAL_P(bind->zval)[ Z_STRLEN_P(bind->zval) ] = '\0';
 	} else if (Z_TYPE_P(bind->zval) == IS_ARRAY) {

Modified: php/php-src/trunk/ext/oci8/tests/bind_empty.phpt
===================================================================
--- php/php-src/trunk/ext/oci8/tests/bind_empty.phpt	2010-04-29 05:07:03 UTC (rev 298754)
+++ php/php-src/trunk/ext/oci8/tests/bind_empty.phpt	2010-04-29 05:07:16 UTC (rev 298755)
@@ -7,11 +7,11 @@

 require dirname(__FILE__).'/connect.inc';

-$drop = "DROP table bind_test";
+$drop = "DROP table bind_empty_tab";
 $statement = oci_parse($c, $drop);
 @oci_execute($statement);

-$create = "CREATE table bind_test(name VARCHAR(10))";
+$create = "CREATE table bind_empty_tab(name VARCHAR(10))";
 $statement = oci_parse($c, $create);
 oci_execute($statement);

@@ -19,7 +19,7 @@
 echo "Test 1\n";

 $name = null;
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name");
 oci_bind_by_name($stmt, ":name", $name);

 var_dump(oci_execute($stmt));
@@ -27,26 +27,26 @@
 echo "Test 2\n";

 $name = "";
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name");
 oci_bind_by_name($stmt, ":name", $name);

 var_dump(oci_execute($stmt));

 echo "Test 3\n";

-$stmt = oci_parse($c, "INSERT INTO bind_test (NAME) VALUES ('abc')");
+$stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('abc')");
 $res = oci_execute($stmt);

-$stmt = oci_parse($c, "INSERT INTO bind_test (NAME) VALUES ('def')");
+$stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('def')");
 $res = oci_execute($stmt);

 $name = null;
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name WHERE NAME = 'abc'");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name WHERE NAME = 'abc'");
 oci_bind_by_name($stmt, ":name", $name);

 var_dump(oci_execute($stmt));

-$stid = oci_parse($c, "select * from bind_test order by 1");
+$stid = oci_parse($c, "select * from bind_empty_tab order by 1");
 oci_execute($stid);
 oci_fetch_all($stid, $res);
 var_dump($res);
@@ -54,26 +54,43 @@
 echo "Test 4\n";

 $name = "";
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name WHERE NAME = 'def'");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name WHERE NAME = 'def'");
 oci_bind_by_name($stmt, ":name", $name);

 var_dump(oci_execute($stmt));

-$stid = oci_parse($c, "select * from bind_test order by 1");
+$stid = oci_parse($c, "select * from bind_empty_tab order by 1");
 oci_execute($stid);
 oci_fetch_all($stid, $res);
 var_dump($res);

+echo "Test 5\n";

+$av = $bv = 'old';
+$s = oci_parse($c, "begin :bv := null; end; ");
+oci_bind_by_name($s, ":bv", $bv);
+oci_execute($s);
+var_dump($av);
+var_dump($bv);
+
+echo "Test 6\n";
+
+$av = $bv = null;
+$s = oci_parse($c, "begin :bv := null; end; ");
+oci_bind_by_name($s, ":bv", $bv);
+oci_execute($s);
+var_dump($av);
+var_dump($bv);
+
 // Clean up

-$drop = "DROP table bind_test";
+$drop = "DROP table bind_empty_tab";
 $statement = oci_parse($c, $drop);
 @oci_execute($statement);

-echo "Done\n";
-
 ?>
+===DONE===
+<?php exit(0); ?>
 --EXPECTF--
 Test 1
 bool(true)
@@ -101,4 +118,10 @@
     NULL
   }
 }
-Done
+Test 5
+string(3) "old"
+NULL
+Test 6
+NULL
+NULL
+===DONE===
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to