|
|
| version 1.1.1.1, 2012/02/21 23:47:59 | version 1.1.1.2, 2012/05/29 12:34:41 |
|---|---|
| Line 2503 static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PAR | Line 2503 static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PAR |
| int should_copy=0; | int should_copy=0; |
| const uint element_len = strlen(element); | const uint element_len = strlen(element); |
| if (PG(magic_quotes_runtime)) { | data = safe_estrndup(element, element_len); |
| data = php_addslashes(element, element_len, &data_len, 0 TSRMLS_CC); | data_len = element_len; |
| } else { | |
| data = safe_estrndup(element, element_len); | |
| data_len = element_len; | |
| } | |
| if (result_type & PGSQL_NUM) { | if (result_type & PGSQL_NUM) { |
| add_index_stringl(return_value, i, data, data_len, should_copy); | add_index_stringl(return_value, i, data, data_len, should_copy); |
| Line 2883 PHP_FUNCTION(pg_trace) | Line 2879 PHP_FUNCTION(pg_trace) |
| ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink); | ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink); |
| stream = php_stream_open_wrapper(z_filename, mode, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL); | stream = php_stream_open_wrapper(z_filename, mode, REPORT_ERRORS, NULL); |
| if (!stream) { | if (!stream) { |
| RETURN_FALSE; | RETURN_FALSE; |
| Line 3173 PHP_FUNCTION(pg_lo_open) | Line 3169 PHP_FUNCTION(pg_lo_open) |
| } else { | } else { |
| pgsql_lofp->conn = pgsql; | pgsql_lofp->conn = pgsql; |
| pgsql_lofp->lofd = pgsql_lofd; | pgsql_lofp->lofd = pgsql_lofd; |
| Z_LVAL_P(return_value) = zend_list_insert(pgsql_lofp, le_lofp); | Z_LVAL_P(return_value) = zend_list_insert(pgsql_lofp, le_lofp TSRMLS_CC); |
| Z_TYPE_P(return_value) = IS_LONG; | Z_TYPE_P(return_value) = IS_LONG; |
| } | } |
| } | } |
| Line 3326 PHP_FUNCTION(pg_lo_import) | Line 3322 PHP_FUNCTION(pg_lo_import) |
| Oid returned_oid; | Oid returned_oid; |
| if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, | if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, |
| "rs|z", &pgsql_link, &file_in, &name_len, &oid) == SUCCESS) { | "rp|z", &pgsql_link, &file_in, &name_len, &oid) == SUCCESS) { |
| ; | ; |
| } | } |
| else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, | else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, |
| "s|z", &file_in, &name_len, &oid) == SUCCESS) { | "p|z", &file_in, &name_len, &oid) == SUCCESS) { |
| id = PGG(default_link); | id = PGG(default_link); |
| CHECK_DEFAULT_LINK(id); | CHECK_DEFAULT_LINK(id); |
| } | } |
| /* old calling convention, deprecated since PHP 4.2 */ | /* old calling convention, deprecated since PHP 4.2 */ |
| else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, | else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, |
| "sr", &file_in, &name_len, &pgsql_link ) == SUCCESS) { | "pr", &file_in, &name_len, &pgsql_link ) == SUCCESS) { |
| php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Old API is used"); | php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Old API is used"); |
| } | } |
| else { | else { |
| WRONG_PARAM_COUNT; | WRONG_PARAM_COUNT; |
| } | } |
| if (strlen(file_in) != name_len) { | |
| RETURN_FALSE; | |
| } | |
| if (PG(safe_mode) &&(!php_checkuid(file_in, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { | |
| RETURN_FALSE; | |
| } | |
| if (php_check_open_basedir(file_in TSRMLS_CC)) { | if (php_check_open_basedir(file_in TSRMLS_CC)) { |
| RETURN_FALSE; | RETURN_FALSE; |
| Line 3424 PHP_FUNCTION(pg_lo_export) | Line 3412 PHP_FUNCTION(pg_lo_export) |
| /* allow string to handle large OID value correctly */ | /* allow string to handle large OID value correctly */ |
| if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, | if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, |
| "rls", &pgsql_link, &oid_long, &file_out, &name_len) == SUCCESS) { | "rlp", &pgsql_link, &oid_long, &file_out, &name_len) == SUCCESS) { |
| if (oid_long <= InvalidOid) { | if (oid_long <= InvalidOid) { |
| php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid OID specified"); | php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid OID specified"); |
| RETURN_FALSE; | RETURN_FALSE; |
| Line 3441 PHP_FUNCTION(pg_lo_export) | Line 3429 PHP_FUNCTION(pg_lo_export) |
| } | } |
| } | } |
| else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, | else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, |
| "ls", &oid_long, &file_out, &name_len) == SUCCESS) { | "lp", &oid_long, &file_out, &name_len) == SUCCESS) { |
| if (oid_long <= InvalidOid) { | if (oid_long <= InvalidOid) { |
| php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid OID specified"); | php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid OID specified"); |
| RETURN_FALSE; | RETURN_FALSE; |
| Line 3451 PHP_FUNCTION(pg_lo_export) | Line 3439 PHP_FUNCTION(pg_lo_export) |
| CHECK_DEFAULT_LINK(id); | CHECK_DEFAULT_LINK(id); |
| } | } |
| else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, | else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, |
| "ss", &oid_string, &oid_strlen, &file_out, &name_len) == SUCCESS) { | "sp", &oid_string, &oid_strlen, &file_out, &name_len) == SUCCESS) { |
| oid = (Oid)strtoul(oid_string, &end_ptr, 10); | oid = (Oid)strtoul(oid_string, &end_ptr, 10); |
| if ((oid_string+oid_strlen) != end_ptr) { | if ((oid_string+oid_strlen) != end_ptr) { |
| /* wrong integer format */ | /* wrong integer format */ |
| Line 3462 PHP_FUNCTION(pg_lo_export) | Line 3450 PHP_FUNCTION(pg_lo_export) |
| CHECK_DEFAULT_LINK(id); | CHECK_DEFAULT_LINK(id); |
| } | } |
| else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, | else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, |
| "ssr", &oid_string, &oid_strlen, &file_out, &name_len, &pgsql_link) == SUCCESS) { | "spr", &oid_string, &oid_strlen, &file_out, &name_len, &pgsql_link) == SUCCESS) { |
| oid = (Oid)strtoul(oid_string, &end_ptr, 10); | oid = (Oid)strtoul(oid_string, &end_ptr, 10); |
| if ((oid_string+oid_strlen) != end_ptr) { | if ((oid_string+oid_strlen) != end_ptr) { |
| /* wrong integer format */ | /* wrong integer format */ |
| Line 3471 PHP_FUNCTION(pg_lo_export) | Line 3459 PHP_FUNCTION(pg_lo_export) |
| } | } |
| } | } |
| else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, | else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, |
| "lsr", &oid_long, &file_out, &name_len, &pgsql_link) == SUCCESS) { | "lpr", &oid_long, &file_out, &name_len, &pgsql_link) == SUCCESS) { |
| php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Old API is used"); | php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Old API is used"); |
| if (oid_long <= InvalidOid) { | if (oid_long <= InvalidOid) { |
| php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid OID specified"); | php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid OID specified"); |
| Line 3483 PHP_FUNCTION(pg_lo_export) | Line 3471 PHP_FUNCTION(pg_lo_export) |
| php_error_docref(NULL TSRMLS_CC, E_WARNING, "Requires 2 or 3 arguments"); | php_error_docref(NULL TSRMLS_CC, E_WARNING, "Requires 2 or 3 arguments"); |
| RETURN_FALSE; | RETURN_FALSE; |
| } | } |
| if (strlen(file_out) != name_len) { | |
| RETURN_FALSE; | |
| } | |
| if (PG(safe_mode) &&(!php_checkuid(file_out, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { | |
| RETURN_FALSE; | |
| } | |
| if (php_check_open_basedir(file_out TSRMLS_CC)) { | if (php_check_open_basedir(file_out TSRMLS_CC)) { |
| RETURN_FALSE; | RETURN_FALSE; |
| Line 6233 PHP_PGSQL_API int php_pgsql_result2array(PGresult *pg_ | Line 6213 PHP_PGSQL_API int php_pgsql_result2array(PGresult *pg_ |
| size_t data_len; | size_t data_len; |
| const size_t element_len = strlen(element); | const size_t element_len = strlen(element); |
| if (PG(magic_quotes_runtime)) { | data = safe_estrndup(element, element_len); |
| data = php_addslashes(element, element_len, &data_len, 0 TSRMLS_CC); | data_len = element_len; |
| } else { | |
| data = safe_estrndup(element, element_len); | |
| data_len = element_len; | |
| } | |
| field_name = PQfname(pg_result, i); | field_name = PQfname(pg_result, i); |
| add_assoc_stringl(row, field_name, data, data_len, 0); | add_assoc_stringl(row, field_name, data, data_len, 0); |
| } | } |