1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 09:12:14 +01:00

off by one error

This commit is contained in:
George Schlossnagle
2004-05-20 18:44:12 +00:00
parent 3366916203
commit c22cb0477c
2 changed files with 10 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
/* Generated by re2c 0.5 on Thu May 20 13:12:59 2004 */
/* Generated by re2c 0.5 on Thu May 20 13:51:55 2004 */
#line 1 "/home/george/src/pecl/pdo/pdo_sql_parser.re"
/*
+----------------------------------------------------------------------+
@@ -232,12 +232,14 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
if(!params) {
/* error */
efree(*outquery);
*outquery = NULL;
return (int) (s.cur - inquery);
}
/* lookup bind first via hash and then index */
/* stupid keys need to be null-terminated, even though we know their length */
crutch = s.tok[s.cur-s.tok + 1];
crutch = s.tok[s.cur-s.tok];
s.tok[s.cur-s.tok] = '\0';
fprintf(stderr, "looking up key: (%.*s)", s.cur-s.tok + 1, s.tok);
if((SUCCESS == zend_hash_find(params, s.tok, s.cur-s.tok + 1,(void **)&param))
||
(SUCCESS == zend_hash_index_find(params, bindno, (void **)&param)))
@@ -265,6 +267,7 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
else {
/* error and cleanup */
efree(*outquery);
*outquery = NULL;
return (int) (s.cur - inquery);
}
bindno++;
@@ -273,6 +276,7 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
if(!params) {
/* error */
efree(*outquery);
*outquery = NULL;
return (int) (s.cur - inquery);
}
/* lookup bind by index */
@@ -299,12 +303,14 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
else {
/* error and cleanup */
efree(*outquery);
*outquery = NULL;
return (int) (s.cur - inquery);
}
bindno++;
}
}
*ptr = '\0';
fprintf(stderr, "good\n");
return 0;
}

View File

@@ -121,7 +121,7 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
}
/* lookup bind first via hash and then index */
/* stupid keys need to be null-terminated, even though we know their length */
crutch = s.tok[s.cur-s.tok + 1];
crutch = s.tok[s.cur-s.tok];
s.tok[s.cur-s.tok] = '\0';
if((SUCCESS == zend_hash_find(params, s.tok, s.cur-s.tok + 1,(void **)&param))
||
@@ -147,7 +147,7 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
*outquery_len += (Z_STRLEN_P(param->parameter));
}
}
else_{
else {
/* error and cleanup */
efree(*outquery);
*outquery = NULL;