diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2007-03-06 00:52:55 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2007-03-06 00:52:55 +0000 |
commit | ff3e8250834b2118ba259e2791fffffdb855c315 (patch) | |
tree | 4cf08cc21a0306a8c13ac25456475f9819f11f56 /ext/pdo/pdo_sql_parser.c | |
parent | 7508066230aeea7eab20e63a4559068e00f4d9f5 (diff) | |
download | php-git-ff3e8250834b2118ba259e2791fffffdb855c315.tar.gz |
Fixed bug #40417 (Allow multiple instances of the same named PDO token in
prepared statement emulation code).
Diffstat (limited to 'ext/pdo/pdo_sql_parser.c')
-rw-r--r-- | ext/pdo/pdo_sql_parser.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c index c2b508cd97..2a8066a0da 100644 --- a/ext/pdo/pdo_sql_parser.c +++ b/ext/pdo/pdo_sql_parser.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.11.0 on Thu Feb 1 19:01:11 2007 */ +/* Generated by re2c 0.11.0 on Mon Mar 5 19:42:28 2007 */ #line 1 "ext/pdo/pdo_sql_parser.re" /* +----------------------------------------------------------------------+ @@ -280,13 +280,25 @@ PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, } if (params && bindno != zend_hash_num_elements(params) && stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) { + /* extra bit of validation for instances when same params are bound more then once */ + if (query_type != PDO_PLACEHOLDER_POSITIONAL && bindno > zend_hash_num_elements(params)) { + int ok = 1; + for (plc = placeholders; plc; plc = plc->next) { + if (zend_hash_find(params, plc->pos, plc->len, (void**) ¶m) == FAILURE) { + ok = 0; + break; + } + } + if (ok) { + goto safe; + } + } pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "number of bound variables does not match number of tokens" TSRMLS_CC); ret = -1; goto clean_up; } - +safe: /* what are we going to do ? */ - if (stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) { /* query generation */ |