summaryrefslogtreecommitdiff
path: root/ext/pdo/pdo_sql_parser.c
diff options
context:
space:
mode:
authorGeorge Schlossnagle <gschlossnagle@php.net>2004-05-20 17:34:52 +0000
committerGeorge Schlossnagle <gschlossnagle@php.net>2004-05-20 17:34:52 +0000
commite3e2370490914272d7b7ca44888526d189b9e85e (patch)
tree18082b6319e4a76a25f0fdb9351664e078698b0a /ext/pdo/pdo_sql_parser.c
parent04ccc0134d933931431e298c80c6aa699065fad9 (diff)
downloadphp-git-e3e2370490914272d7b7ca44888526d189b9e85e.tar.gz
keys need to be null-terminated (how did this not get committed before???)
bind-by-name includes the leading : in the name
Diffstat (limited to 'ext/pdo/pdo_sql_parser.c')
-rw-r--r--ext/pdo/pdo_sql_parser.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c
index 00b131ceb7..3677157204 100644
--- a/ext/pdo/pdo_sql_parser.c
+++ b/ext/pdo/pdo_sql_parser.c
@@ -1,5 +1,5 @@
-/* Generated by re2c 0.5 on Tue May 18 15:32:50 2004 */
-#line 1 "/home/rei/php5/ext/pdo/pdo_sql_parser.re"
+/* Generated by re2c 0.5 on Thu May 20 12:43:08 2004 */
+#line 1 "/home/george/src/pecl/pdo/pdo_sql_parser.re"
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
@@ -62,7 +62,7 @@ static int scan(Scanner *s)
160, 224, 224, 224, 224, 224, 224, 224,
224, 224, 224, 224, 224, 224, 224, 224,
224, 224, 224, 224, 224, 224, 224, 224,
- 224, 224, 224, 160, 32, 160, 160, 160,
+ 224, 224, 224, 160, 32, 160, 160, 224,
160, 224, 224, 224, 224, 224, 224, 224,
224, 224, 224, 224, 224, 224, 224, 224,
224, 224, 224, 224, 224, 224, 224, 224,
@@ -192,18 +192,24 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
*outquery_len += (s.cur - s.tok);
}
else if(t == PDO_PARSER_BIND) {
+ char crutch;
if(!params) {
/* error */
efree(*outquery);
return 0;
}
/* lookup bind first via hash and then index */
- if((SUCCESS == zend_hash_find(params, s.tok+1, s.cur-s.tok,(void **)&param))
+ /* stupid keys need to be null-terminated, even though we know their length */
+ crutch = s.tok[s.cur-s.tok + 1];
+ s.tok[s.cur-s.tok] = '\0';
+ if((SUCCESS == zend_hash_find(params, s.tok, s.cur-s.tok + 1,(void **)&param))
||
(SUCCESS == zend_hash_index_find(params, bindno, (void **)&param)))
{
char *quotedstr;
int quotedstrlen;
+ /* restore the in-string key, doesn't need null-termination here */
+ s.tok[s.cur-s.tok] = crutch;
/* currently everything is a string here */
/* quote the bind value if necessary */