mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
- Fixed bug #52512 (Broken error handling in odbc_execute)
patch by: mkoegler at auto dot tuwien dot ac dot at
This commit is contained in:
parent
50863932a6
commit
e6bef6735f
2 changed files with 45 additions and 2 deletions
2
NEWS
2
NEWS
|
@ -134,6 +134,8 @@
|
|||
- Fixed bug #52546 (pdo_dblib segmentation fault when iterating MONEY values).
|
||||
(Felipe)
|
||||
- Fixed bug #52534 (var_export array with negative key). (Felipe)
|
||||
- Fixed bug #52512 (Broken error handling in odbc_execute).
|
||||
(mkoegler at auto dot tuwien dot ac dot at)
|
||||
- Fixed bug #52508 (newline problem with parse_ini_file+INI_SCANNER_RAW).
|
||||
(Felipe)
|
||||
- Fixed bug #52498 (libevent was not only linked to php-fpm). (fat)
|
||||
|
|
|
@ -1262,11 +1262,19 @@ PHP_FUNCTION(odbc_execute)
|
|||
|
||||
zend_hash_internal_pointer_reset(Z_ARRVAL_P(pv_param_arr));
|
||||
params = (params_t *)safe_emalloc(sizeof(params_t), result->numparams, 0);
|
||||
for(i = 0; i < result->numparams; i++) {
|
||||
params[i].fp = -1;
|
||||
}
|
||||
|
||||
for(i = 1; i <= result->numparams; i++) {
|
||||
if (zend_hash_get_current_data(Z_ARRVAL_P(pv_param_arr), (void **) &tmp) == FAILURE) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error getting parameter");
|
||||
SQLFreeStmt(result->stmt,SQL_RESET_PARAMS);
|
||||
for (i = 0; i < result->numparams; i++) {
|
||||
if (params[i].fp != -1) {
|
||||
close(params[i].fp);
|
||||
}
|
||||
}
|
||||
efree(params);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -1276,13 +1284,29 @@ PHP_FUNCTION(odbc_execute)
|
|||
if (Z_TYPE_PP(tmp) != IS_STRING) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter");
|
||||
SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
|
||||
for (i = 0; i < result->numparams; i++) {
|
||||
if (params[i].fp != -1) {
|
||||
close(params[i].fp);
|
||||
}
|
||||
}
|
||||
efree(params);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
SQLDescribeParam(result->stmt, (SQLUSMALLINT)i, &sqltype, &precision, &scale, &nullable);
|
||||
rc = SQLDescribeParam(result->stmt, (SQLUSMALLINT)i, &sqltype, &precision, &scale, &nullable);
|
||||
params[i-1].vallen = Z_STRLEN_PP(tmp);
|
||||
params[i-1].fp = -1;
|
||||
if (rc == SQL_ERROR) {
|
||||
odbc_sql_error(result->conn_ptr, result->stmt, "SQLDescribeParameter");
|
||||
SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
|
||||
for (i = 0; i < result->numparams; i++) {
|
||||
if (params[i].fp != -1) {
|
||||
close(params[i].fp);
|
||||
}
|
||||
}
|
||||
efree(params);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (IS_SQL_BINARY(sqltype)) {
|
||||
ctype = SQL_C_BINARY;
|
||||
|
@ -1306,6 +1330,12 @@ PHP_FUNCTION(odbc_execute)
|
|||
/* Check the basedir */
|
||||
if (php_check_open_basedir(filename TSRMLS_CC)) {
|
||||
efree(filename);
|
||||
SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
|
||||
for (i = 0; i < result->numparams; i++) {
|
||||
if (params[i].fp != -1) {
|
||||
close(params[i].fp);
|
||||
}
|
||||
}
|
||||
efree(params);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -1313,7 +1343,7 @@ PHP_FUNCTION(odbc_execute)
|
|||
if ((params[i-1].fp = open(filename,O_RDONLY)) == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Can't open file %s", filename);
|
||||
SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
|
||||
for(i = 0; i < result->numparams; i++) {
|
||||
for (i = 0; i < result->numparams; i++) {
|
||||
if (params[i].fp != -1) {
|
||||
close(params[i].fp);
|
||||
}
|
||||
|
@ -1344,6 +1374,17 @@ PHP_FUNCTION(odbc_execute)
|
|||
Z_STRVAL_PP(tmp), 0,
|
||||
¶ms[i-1].vallen);
|
||||
}
|
||||
if (rc == SQL_ERROR) {
|
||||
odbc_sql_error(result->conn_ptr, result->stmt, "SQLBindParameter");
|
||||
SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
|
||||
for (i = 0; i < result->numparams; i++) {
|
||||
if (params[i].fp != -1) {
|
||||
close(params[i].fp);
|
||||
}
|
||||
}
|
||||
efree(params);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
zend_hash_move_forward(Z_ARRVAL_P(pv_param_arr));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue