sixd                                     Tue, 07 Jun 2011 23:53:02 +0000

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

Log:
Sync OCI8 branches. Allow 'pecl install' to work on both PHP 5.3 & 5.4

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/oci8/oci8.c
    U   php/php-src/branches/PHP_5_3/ext/oci8/oci8_interface.c
    U   php/php-src/branches/PHP_5_3/ext/oci8/oci8_lob.c
    U   php/php-src/branches/PHP_5_3/ext/oci8/php_oci8.h
    U   php/php-src/branches/PHP_5_4/ext/oci8/oci8.c
    U   php/php-src/branches/PHP_5_4/ext/oci8/oci8_interface.c
    U   php/php-src/branches/PHP_5_4/ext/oci8/oci8_lob.c
    U   php/php-src/branches/PHP_5_4/ext/oci8/php_oci8.h
    U   php/php-src/trunk/ext/oci8/oci8.c
    U   php/php-src/trunk/ext/oci8/oci8_interface.c
    U   php/php-src/trunk/ext/oci8/oci8_lob.c
    U   php/php-src/trunk/ext/oci8/php_oci8.h

Modified: php/php-src/branches/PHP_5_3/ext/oci8/oci8.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/oci8/oci8.c	2011-06-07 23:29:22 UTC (rev 311904)
+++ php/php-src/branches/PHP_5_3/ext/oci8/oci8.c	2011-06-07 23:53:02 UTC (rev 311905)
@@ -1042,7 +1042,7 @@
 #endif
 		if (OCI_G(env)
 			&& OCIErrorGet(OCI_G(env), (ub4)1, NULL, &ora_error_code, tmp_buf, (ub4)PHP_OCI_ERRBUF_LEN, (ub4)OCI_HTYPE_ENV) == OCI_SUCCESS
-  			&& *tmp_buf) {
+			&& *tmp_buf) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", tmp_buf);
 		}

@@ -1754,13 +1754,13 @@
 				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Privileged connect is disabled. Enable oci8.privileged_connect to be able to connect as SYSOPER or SYSDBA");
 				return NULL;
 			}
-			/*	Disable privileged connections in Safe Mode (N.b. safe mode has been removed in PHP
-			 *	6 anyway)
-			 */
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+			/* Safe mode has been removed in PHP 5.4 */
 			if (PG(safe_mode)) {
 				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Privileged connect is disabled in Safe Mode");
 				return NULL;
 			}
+#endif
 		}
 	}

@@ -1922,7 +1922,11 @@
 								memcmp(tmp->hash_key, hashed_details.c, hashed_details.len) == 0 && zend_list_addref(connection->rsrc_id) == SUCCESS) {
 								/* do nothing */
 							} else {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
+								connection->rsrc_id = zend_list_insert(connection, le_pconnection TSRMLS_CC);
+#else
 								connection->rsrc_id = zend_list_insert(connection, le_pconnection);
+#endif
 								/* Persistent connections: For old close semantics we artificially
 								 * bump up the refcount to prevent the non-persistent destructor
 								 * from getting called until request shutdown. The refcount is
@@ -2066,7 +2070,11 @@
 		new_le.ptr = connection;
 		new_le.type = le_pconnection;
 		connection->used_this_request = 1;
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
+		connection->rsrc_id = zend_list_insert(connection, le_pconnection TSRMLS_CC);
+#else
 		connection->rsrc_id = zend_list_insert(connection, le_pconnection);
+#endif

 		/* Persistent connections: For old close semantics we artificially bump up the refcount to
 		 * prevent the non-persistent destructor from getting called until request shutdown. The
@@ -2079,13 +2087,21 @@
 		OCI_G(num_persistent)++;
 		OCI_G(num_links)++;
 	} else if (!exclusive) {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
+		connection->rsrc_id = zend_list_insert(connection, le_connection TSRMLS_CC);
+#else
 		connection->rsrc_id = zend_list_insert(connection, le_connection);
+#endif
 		new_le.ptr = (void *)connection->rsrc_id;
 		new_le.type = le_index_ptr;
 		zend_hash_update(&EG(regular_list), connection->hash_key, strlen(connection->hash_key)+1, (void *)&new_le, sizeof(zend_rsrc_list_entry), NULL);
 		OCI_G(num_links)++;
 	} else {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
+		connection->rsrc_id = zend_list_insert(connection, le_connection TSRMLS_CC);
+#else
 		connection->rsrc_id = zend_list_insert(connection, le_connection);
+#endif
 		OCI_G(num_links)++;
 	}

@@ -2778,7 +2794,11 @@
 		}
 		spool_le.ptr  = session_pool;
 		spool_le.type = le_psessionpool;
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
+		zend_list_insert(session_pool, le_psessionpool TSRMLS_CC);
+#else
 		zend_list_insert(session_pool, le_psessionpool);
+#endif
 		zend_hash_update(&EG(persistent_list), session_pool->spool_hash_key, strlen(session_pool->spool_hash_key)+1,(void *)&spool_le, sizeof(zend_rsrc_list_entry),NULL);
 	} else if (spool_out_le->type == le_psessionpool &&
 		strlen(((php_oci_spool *)(spool_out_le->ptr))->spool_hash_key) == spool_hashed_details.len &&

Modified: php/php-src/branches/PHP_5_3/ext/oci8/oci8_interface.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/oci8/oci8_interface.c	2011-06-07 23:29:22 UTC (rev 311904)
+++ php/php-src/branches/PHP_5_3/ext/oci8/oci8_interface.c	2011-06-07 23:53:02 UTC (rev 311905)
@@ -233,26 +233,37 @@
 	int filename_len;

 	if (getThis()) {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
+#else
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
+#endif
 			return;
 		}
 	}
 	else {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Op", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len) == FAILURE) {
+#else
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len) == FAILURE) {
+#endif
 			return;
 		}
 	}

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+	/* The "p" parsing parameter handles this case in PHP 5.4+ */
 	if (strlen(filename) != filename_len) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename cannot contain null bytes");
 		RETURN_FALSE;
 	}
+#endif

 	if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
 		RETURN_FALSE;
 	}
-
+
 	PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);

 	if (php_oci_lob_import(descriptor, filename TSRMLS_CC)) {
@@ -641,12 +652,12 @@
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &offset, &length) == FAILURE) {
 			return;
 		}
-
+
 		if (ZEND_NUM_ARGS() > 0 && offset < 0) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset must be greater than or equal to 0");
 			RETURN_FALSE;
 		}
-
+
 		if (ZEND_NUM_ARGS() > 1 && length < 0) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length must be greater than or equal to 0");
 			RETURN_FALSE;
@@ -656,7 +667,7 @@
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|ll", &z_descriptor, oci_lob_class_entry_ptr, &offset, &length) == FAILURE) {
 			return;
 		}
-
+
 		if (ZEND_NUM_ARGS() > 1 && offset < 0) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset must be greater than or equal to 0");
 			RETURN_FALSE;
@@ -674,7 +685,7 @@
 	}

 	PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
-
+
 	if (php_oci_lob_erase(descriptor, offset, length, &bytes_erased TSRMLS_CC)) {
 		RETURN_FALSE;
 	}
@@ -872,7 +883,11 @@
 	ub4 lob_length;

 	if (getThis()) {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|ll", &filename, &filename_len, &start, &length) == FAILURE) {
+#else
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &filename, &filename_len, &start, &length) == FAILURE) {
+#endif
 			return;
 		}

@@ -886,7 +901,11 @@
 		}
 	}
 	else {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Op|ll", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len, &start, &length) == FAILURE) {
+#else
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os|ll", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len, &start, &length) == FAILURE) {
+#endif
 			return;
 		}

@@ -900,10 +919,13 @@
 		}
 	}

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+	/* The "p" parsing parameter handles this case in PHP 5.4+ */
 	if (strlen(filename) != filename_len) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename cannot contain null bytes");
 		RETURN_FALSE;
 	}
+#endif

 	if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
@@ -929,15 +951,22 @@
 		RETURN_FALSE;
 	}

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+	/* Safe mode has been removed in PHP 5.4 */
 	if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
 		RETURN_FALSE;
 	}
+#endif

 	if (php_check_open_basedir(filename TSRMLS_CC)) {
 		RETURN_FALSE;
 	}

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
+	stream = php_stream_open_wrapper_ex(filename, "w", REPORT_ERRORS, NULL, NULL);
+#else
 	stream = php_stream_open_wrapper_ex(filename, "w", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, NULL);
+#endif

 	block_length = PHP_OCI_LOB_BUFFER_SIZE;
 	if (block_length > length) {
@@ -1881,11 +1910,13 @@
 	int user_len, pass_old_len, pass_new_len, dbname_len;
 	php_oci_connection *connection;

-	/*	Disable in Safe Mode  */
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+	/* Safe mode has been removed in PHP 5.4 */
 	if (PG(safe_mode)) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "is disabled in Safe Mode");
 		RETURN_FALSE;
 	}
+#endif

 	if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "rsss", &z_connection, &user, &user_len, &pass_old, &pass_old_len, &pass_new, &pass_new_len) == SUCCESS) {
 		PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);

Modified: php/php-src/branches/PHP_5_3/ext/oci8/oci8_lob.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/oci8/oci8_lob.c	2011-06-07 23:29:22 UTC (rev 311904)
+++ php/php-src/branches/PHP_5_3/ext/oci8/oci8_lob.c	2011-06-07 23:53:02 UTC (rev 311905)
@@ -724,7 +724,12 @@
 	char buf[8192];
 	ub4 offset = 1;

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
+	/* Safe mode has been removed in PHP 5.4 */
+	if (php_check_open_basedir(filename TSRMLS_CC)) {
+#else
 	if ((PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename TSRMLS_CC)) {
+#endif
 		return 1;
 	}


Modified: php/php-src/branches/PHP_5_3/ext/oci8/php_oci8.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/oci8/php_oci8.h	2011-06-07 23:29:22 UTC (rev 311904)
+++ php/php-src/branches/PHP_5_3/ext/oci8/php_oci8.h	2011-06-07 23:53:02 UTC (rev 311905)
@@ -46,7 +46,7 @@
  */
 #undef PHP_OCI8_VERSION
 #endif
-#define PHP_OCI8_VERSION "1.4.5"
+#define PHP_OCI8_VERSION "1.4.6-dev"

 extern zend_module_entry oci8_module_entry;
 #define phpext_oci8_ptr &oci8_module_entry

Modified: php/php-src/branches/PHP_5_4/ext/oci8/oci8.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/oci8/oci8.c	2011-06-07 23:29:22 UTC (rev 311904)
+++ php/php-src/branches/PHP_5_4/ext/oci8/oci8.c	2011-06-07 23:53:02 UTC (rev 311905)
@@ -1754,6 +1754,13 @@
 				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Privileged connect is disabled. Enable oci8.privileged_connect to be able to connect as SYSOPER or SYSDBA");
 				return NULL;
 			}
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+			/* Safe mode has been removed in PHP 5.4 */
+			if (PG(safe_mode)) {
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Privileged connect is disabled in Safe Mode");
+				return NULL;
+			}
+#endif
 		}
 	}

@@ -1915,7 +1922,11 @@
 								memcmp(tmp->hash_key, hashed_details.c, hashed_details.len) == 0 && zend_list_addref(connection->rsrc_id) == SUCCESS) {
 								/* do nothing */
 							} else {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 								connection->rsrc_id = zend_list_insert(connection, le_pconnection TSRMLS_CC);
+#else
+								connection->rsrc_id = zend_list_insert(connection, le_pconnection);
+#endif
 								/* Persistent connections: For old close semantics we artificially
 								 * bump up the refcount to prevent the non-persistent destructor
 								 * from getting called until request shutdown. The refcount is
@@ -2059,7 +2070,11 @@
 		new_le.ptr = connection;
 		new_le.type = le_pconnection;
 		connection->used_this_request = 1;
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		connection->rsrc_id = zend_list_insert(connection, le_pconnection TSRMLS_CC);
+#else
+		connection->rsrc_id = zend_list_insert(connection, le_pconnection);
+#endif

 		/* Persistent connections: For old close semantics we artificially bump up the refcount to
 		 * prevent the non-persistent destructor from getting called until request shutdown. The
@@ -2072,13 +2087,21 @@
 		OCI_G(num_persistent)++;
 		OCI_G(num_links)++;
 	} else if (!exclusive) {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		connection->rsrc_id = zend_list_insert(connection, le_connection TSRMLS_CC);
+#else
+		connection->rsrc_id = zend_list_insert(connection, le_connection);
+#endif
 		new_le.ptr = (void *)connection->rsrc_id;
 		new_le.type = le_index_ptr;
 		zend_hash_update(&EG(regular_list), connection->hash_key, strlen(connection->hash_key)+1, (void *)&new_le, sizeof(zend_rsrc_list_entry), NULL);
 		OCI_G(num_links)++;
 	} else {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		connection->rsrc_id = zend_list_insert(connection, le_connection TSRMLS_CC);
+#else
+		connection->rsrc_id = zend_list_insert(connection, le_connection);
+#endif
 		OCI_G(num_links)++;
 	}

@@ -2771,7 +2794,11 @@
 		}
 		spool_le.ptr  = session_pool;
 		spool_le.type = le_psessionpool;
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		zend_list_insert(session_pool, le_psessionpool TSRMLS_CC);
+#else
+		zend_list_insert(session_pool, le_psessionpool);
+#endif
 		zend_hash_update(&EG(persistent_list), session_pool->spool_hash_key, strlen(session_pool->spool_hash_key)+1,(void *)&spool_le, sizeof(zend_rsrc_list_entry),NULL);
 	} else if (spool_out_le->type == le_psessionpool &&
 		strlen(((php_oci_spool *)(spool_out_le->ptr))->spool_hash_key) == spool_hashed_details.len &&

Modified: php/php-src/branches/PHP_5_4/ext/oci8/oci8_interface.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/oci8/oci8_interface.c	2011-06-07 23:29:22 UTC (rev 311904)
+++ php/php-src/branches/PHP_5_4/ext/oci8/oci8_interface.c	2011-06-07 23:53:02 UTC (rev 311905)
@@ -233,21 +233,37 @@
 	int filename_len;

 	if (getThis()) {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
+#else
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
+#endif
 			return;
 		}
 	}
 	else {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Op", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len) == FAILURE) {
+#else
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len) == FAILURE) {
+#endif
 			return;
 		}
 	}

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+	/* The "p" parsing parameter handles this case in PHP 5.4+ */
+	if (strlen(filename) != filename_len) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename cannot contain null bytes");
+		RETURN_FALSE;
+	}
+#endif
+
 	if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
 		RETURN_FALSE;
 	}
-
+
 	PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);

 	if (php_oci_lob_import(descriptor, filename TSRMLS_CC)) {
@@ -636,12 +652,12 @@
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &offset, &length) == FAILURE) {
 			return;
 		}
-
+
 		if (ZEND_NUM_ARGS() > 0 && offset < 0) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset must be greater than or equal to 0");
 			RETURN_FALSE;
 		}
-
+
 		if (ZEND_NUM_ARGS() > 1 && length < 0) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length must be greater than or equal to 0");
 			RETURN_FALSE;
@@ -651,7 +667,7 @@
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|ll", &z_descriptor, oci_lob_class_entry_ptr, &offset, &length) == FAILURE) {
 			return;
 		}
-
+
 		if (ZEND_NUM_ARGS() > 1 && offset < 0) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset must be greater than or equal to 0");
 			RETURN_FALSE;
@@ -662,14 +678,14 @@
 			RETURN_FALSE;
 		}
 	}
-
+
 	if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
 		RETURN_FALSE;
 	}

 	PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
-
+
 	if (php_oci_lob_erase(descriptor, offset, length, &bytes_erased TSRMLS_CC)) {
 		RETURN_FALSE;
 	}
@@ -867,7 +883,11 @@
 	ub4 lob_length;

 	if (getThis()) {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|ll", &filename, &filename_len, &start, &length) == FAILURE) {
+#else
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &filename, &filename_len, &start, &length) == FAILURE) {
+#endif
 			return;
 		}

@@ -881,7 +901,11 @@
 		}
 	}
 	else {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Op|ll", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len, &start, &length) == FAILURE) {
+#else
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os|ll", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len, &start, &length) == FAILURE) {
+#endif
 			return;
 		}

@@ -895,6 +919,14 @@
 		}
 	}

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+	/* The "p" parsing parameter handles this case in PHP 5.4+ */
+	if (strlen(filename) != filename_len) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename cannot contain null bytes");
+		RETURN_FALSE;
+	}
+#endif
+
 	if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
 		RETURN_FALSE;
@@ -919,11 +951,22 @@
 		RETURN_FALSE;
 	}

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+	/* Safe mode has been removed in PHP 5.4 */
+	if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
+		RETURN_FALSE;
+	}
+#endif
+
 	if (php_check_open_basedir(filename TSRMLS_CC)) {
 		RETURN_FALSE;
 	}

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 	stream = php_stream_open_wrapper_ex(filename, "w", REPORT_ERRORS, NULL, NULL);
+#else
+	stream = php_stream_open_wrapper_ex(filename, "w", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, NULL);
+#endif

 	block_length = PHP_OCI_LOB_BUFFER_SIZE;
 	if (block_length > length) {
@@ -1867,6 +1910,14 @@
 	int user_len, pass_old_len, pass_new_len, dbname_len;
 	php_oci_connection *connection;

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+	/* Safe mode has been removed in PHP 5.4 */
+	if (PG(safe_mode)) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "is disabled in Safe Mode");
+		RETURN_FALSE;
+	}
+#endif
+
 	if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "rsss", &z_connection, &user, &user_len, &pass_old, &pass_old_len, &pass_new, &pass_new_len) == SUCCESS) {
 		PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);


Modified: php/php-src/branches/PHP_5_4/ext/oci8/oci8_lob.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/oci8/oci8_lob.c	2011-06-07 23:29:22 UTC (rev 311904)
+++ php/php-src/branches/PHP_5_4/ext/oci8/oci8_lob.c	2011-06-07 23:53:02 UTC (rev 311905)
@@ -724,7 +724,12 @@
 	char buf[8192];
 	ub4 offset = 1;

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
+	/* Safe mode has been removed in PHP 5.4 */
 	if (php_check_open_basedir(filename TSRMLS_CC)) {
+#else
+	if ((PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename TSRMLS_CC)) {
+#endif
 		return 1;
 	}


Modified: php/php-src/branches/PHP_5_4/ext/oci8/php_oci8.h
===================================================================
--- php/php-src/branches/PHP_5_4/ext/oci8/php_oci8.h	2011-06-07 23:29:22 UTC (rev 311904)
+++ php/php-src/branches/PHP_5_4/ext/oci8/php_oci8.h	2011-06-07 23:53:02 UTC (rev 311905)
@@ -46,7 +46,7 @@
  */
 #undef PHP_OCI8_VERSION
 #endif
-#define PHP_OCI8_VERSION "1.4.5"
+#define PHP_OCI8_VERSION "1.4.6-dev"

 extern zend_module_entry oci8_module_entry;
 #define phpext_oci8_ptr &oci8_module_entry

Modified: php/php-src/trunk/ext/oci8/oci8.c
===================================================================
--- php/php-src/trunk/ext/oci8/oci8.c	2011-06-07 23:29:22 UTC (rev 311904)
+++ php/php-src/trunk/ext/oci8/oci8.c	2011-06-07 23:53:02 UTC (rev 311905)
@@ -1754,6 +1754,13 @@
 				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Privileged connect is disabled. Enable oci8.privileged_connect to be able to connect as SYSOPER or SYSDBA");
 				return NULL;
 			}
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+			/* Safe mode has been removed in PHP 5.4 */
+			if (PG(safe_mode)) {
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Privileged connect is disabled in Safe Mode");
+				return NULL;
+			}
+#endif
 		}
 	}

@@ -1915,7 +1922,11 @@
 								memcmp(tmp->hash_key, hashed_details.c, hashed_details.len) == 0 && zend_list_addref(connection->rsrc_id) == SUCCESS) {
 								/* do nothing */
 							} else {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 								connection->rsrc_id = zend_list_insert(connection, le_pconnection TSRMLS_CC);
+#else
+								connection->rsrc_id = zend_list_insert(connection, le_pconnection);
+#endif
 								/* Persistent connections: For old close semantics we artificially
 								 * bump up the refcount to prevent the non-persistent destructor
 								 * from getting called until request shutdown. The refcount is
@@ -2059,7 +2070,11 @@
 		new_le.ptr = connection;
 		new_le.type = le_pconnection;
 		connection->used_this_request = 1;
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		connection->rsrc_id = zend_list_insert(connection, le_pconnection TSRMLS_CC);
+#else
+		connection->rsrc_id = zend_list_insert(connection, le_pconnection);
+#endif

 		/* Persistent connections: For old close semantics we artificially bump up the refcount to
 		 * prevent the non-persistent destructor from getting called until request shutdown. The
@@ -2072,13 +2087,21 @@
 		OCI_G(num_persistent)++;
 		OCI_G(num_links)++;
 	} else if (!exclusive) {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		connection->rsrc_id = zend_list_insert(connection, le_connection TSRMLS_CC);
+#else
+		connection->rsrc_id = zend_list_insert(connection, le_connection);
+#endif
 		new_le.ptr = (void *)connection->rsrc_id;
 		new_le.type = le_index_ptr;
 		zend_hash_update(&EG(regular_list), connection->hash_key, strlen(connection->hash_key)+1, (void *)&new_le, sizeof(zend_rsrc_list_entry), NULL);
 		OCI_G(num_links)++;
 	} else {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		connection->rsrc_id = zend_list_insert(connection, le_connection TSRMLS_CC);
+#else
+		connection->rsrc_id = zend_list_insert(connection, le_connection);
+#endif
 		OCI_G(num_links)++;
 	}

@@ -2771,7 +2794,11 @@
 		}
 		spool_le.ptr  = session_pool;
 		spool_le.type = le_psessionpool;
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		zend_list_insert(session_pool, le_psessionpool TSRMLS_CC);
+#else
+		zend_list_insert(session_pool, le_psessionpool);
+#endif
 		zend_hash_update(&EG(persistent_list), session_pool->spool_hash_key, strlen(session_pool->spool_hash_key)+1,(void *)&spool_le, sizeof(zend_rsrc_list_entry),NULL);
 	} else if (spool_out_le->type == le_psessionpool &&
 		strlen(((php_oci_spool *)(spool_out_le->ptr))->spool_hash_key) == spool_hashed_details.len &&

Modified: php/php-src/trunk/ext/oci8/oci8_interface.c
===================================================================
--- php/php-src/trunk/ext/oci8/oci8_interface.c	2011-06-07 23:29:22 UTC (rev 311904)
+++ php/php-src/trunk/ext/oci8/oci8_interface.c	2011-06-07 23:53:02 UTC (rev 311905)
@@ -233,21 +233,37 @@
 	int filename_len;

 	if (getThis()) {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
+#else
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
+#endif
 			return;
 		}
 	}
 	else {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Op", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len) == FAILURE) {
+#else
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len) == FAILURE) {
+#endif
 			return;
 		}
 	}

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+	/* The "p" parsing parameter handles this case in PHP 5.4+ */
+	if (strlen(filename) != filename_len) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename cannot contain null bytes");
+		RETURN_FALSE;
+	}
+#endif
+
 	if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
 		RETURN_FALSE;
 	}
-
+
 	PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);

 	if (php_oci_lob_import(descriptor, filename TSRMLS_CC)) {
@@ -636,12 +652,12 @@
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &offset, &length) == FAILURE) {
 			return;
 		}
-
+
 		if (ZEND_NUM_ARGS() > 0 && offset < 0) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset must be greater than or equal to 0");
 			RETURN_FALSE;
 		}
-
+
 		if (ZEND_NUM_ARGS() > 1 && length < 0) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length must be greater than or equal to 0");
 			RETURN_FALSE;
@@ -651,7 +667,7 @@
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|ll", &z_descriptor, oci_lob_class_entry_ptr, &offset, &length) == FAILURE) {
 			return;
 		}
-
+
 		if (ZEND_NUM_ARGS() > 1 && offset < 0) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset must be greater than or equal to 0");
 			RETURN_FALSE;
@@ -662,14 +678,14 @@
 			RETURN_FALSE;
 		}
 	}
-
+
 	if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
 		RETURN_FALSE;
 	}

 	PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
-
+
 	if (php_oci_lob_erase(descriptor, offset, length, &bytes_erased TSRMLS_CC)) {
 		RETURN_FALSE;
 	}
@@ -867,7 +883,11 @@
 	ub4 lob_length;

 	if (getThis()) {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|ll", &filename, &filename_len, &start, &length) == FAILURE) {
+#else
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &filename, &filename_len, &start, &length) == FAILURE) {
+#endif
 			return;
 		}

@@ -881,7 +901,11 @@
 		}
 	}
 	else {
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Op|ll", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len, &start, &length) == FAILURE) {
+#else
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os|ll", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len, &start, &length) == FAILURE) {
+#endif
 			return;
 		}

@@ -895,6 +919,14 @@
 		}
 	}

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+	/* The "p" parsing parameter handles this case in PHP 5.4+ */
+	if (strlen(filename) != filename_len) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename cannot contain null bytes");
+		RETURN_FALSE;
+	}
+#endif
+
 	if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
 		RETURN_FALSE;
@@ -919,11 +951,22 @@
 		RETURN_FALSE;
 	}

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+	/* Safe mode has been removed in PHP 5.4 */
+	if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
+		RETURN_FALSE;
+	}
+#endif
+
 	if (php_check_open_basedir(filename TSRMLS_CC)) {
 		RETURN_FALSE;
 	}

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
 	stream = php_stream_open_wrapper_ex(filename, "w", REPORT_ERRORS, NULL, NULL);
+#else
+	stream = php_stream_open_wrapper_ex(filename, "w", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, NULL);
+#endif

 	block_length = PHP_OCI_LOB_BUFFER_SIZE;
 	if (block_length > length) {
@@ -1867,6 +1910,14 @@
 	int user_len, pass_old_len, pass_new_len, dbname_len;
 	php_oci_connection *connection;

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
+	/* Safe mode has been removed in PHP 5.4 */
+	if (PG(safe_mode)) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "is disabled in Safe Mode");
+		RETURN_FALSE;
+	}
+#endif
+
 	if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "rsss", &z_connection, &user, &user_len, &pass_old, &pass_old_len, &pass_new, &pass_new_len) == SUCCESS) {
 		PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);


Modified: php/php-src/trunk/ext/oci8/oci8_lob.c
===================================================================
--- php/php-src/trunk/ext/oci8/oci8_lob.c	2011-06-07 23:29:22 UTC (rev 311904)
+++ php/php-src/trunk/ext/oci8/oci8_lob.c	2011-06-07 23:53:02 UTC (rev 311905)
@@ -724,7 +724,12 @@
 	char buf[8192];
 	ub4 offset = 1;

+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
+	/* Safe mode has been removed in PHP 5.4 */
 	if (php_check_open_basedir(filename TSRMLS_CC)) {
+#else
+	if ((PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename TSRMLS_CC)) {
+#endif
 		return 1;
 	}


Modified: php/php-src/trunk/ext/oci8/php_oci8.h
===================================================================
--- php/php-src/trunk/ext/oci8/php_oci8.h	2011-06-07 23:29:22 UTC (rev 311904)
+++ php/php-src/trunk/ext/oci8/php_oci8.h	2011-06-07 23:53:02 UTC (rev 311905)
@@ -46,7 +46,7 @@
  */
 #undef PHP_OCI8_VERSION
 #endif
-#define PHP_OCI8_VERSION "1.4.5"
+#define PHP_OCI8_VERSION "1.4.6-dev"

 extern zend_module_entry oci8_module_entry;
 #define phpext_oci8_ptr &oci8_module_entry
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to