mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Avoid copying escaped string, truncate instead
This commit is contained in:
parent
713ac3440c
commit
37989666ef
1 changed files with 5 additions and 5 deletions
|
@ -309,9 +309,7 @@ static zend_string* mysql_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquo
|
||||||
{
|
{
|
||||||
pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
|
pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
|
||||||
bool use_national_character_set = 0;
|
bool use_national_character_set = 0;
|
||||||
char *quoted;
|
|
||||||
size_t quotedlen;
|
size_t quotedlen;
|
||||||
zend_string *quoted_str;
|
|
||||||
|
|
||||||
if (H->assume_national_character_set_strings) {
|
if (H->assume_national_character_set_strings) {
|
||||||
use_national_character_set = 1;
|
use_national_character_set = 1;
|
||||||
|
@ -326,7 +324,9 @@ static zend_string* mysql_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquo
|
||||||
PDO_DBG_ENTER("mysql_handle_quoter");
|
PDO_DBG_ENTER("mysql_handle_quoter");
|
||||||
PDO_DBG_INF_FMT("dbh=%p", dbh);
|
PDO_DBG_INF_FMT("dbh=%p", dbh);
|
||||||
PDO_DBG_INF_FMT("unquoted=%.*s", (int)ZSTR_LEN(unquoted), ZSTR_VAL(unquoted));
|
PDO_DBG_INF_FMT("unquoted=%.*s", (int)ZSTR_LEN(unquoted), ZSTR_VAL(unquoted));
|
||||||
quoted = safe_emalloc(2, ZSTR_LEN(unquoted), 3 + (use_national_character_set ? 1 : 0));
|
|
||||||
|
zend_string *quoted_str = zend_string_safe_alloc(2, ZSTR_LEN(unquoted), 3 + (use_national_character_set ? 1 : 0), false);
|
||||||
|
char *quoted = ZSTR_VAL(quoted_str);
|
||||||
|
|
||||||
if (use_national_character_set) {
|
if (use_national_character_set) {
|
||||||
quotedlen = mysql_real_escape_string_quote(H->server, quoted + 2, ZSTR_VAL(unquoted), ZSTR_LEN(unquoted), '\'');
|
quotedlen = mysql_real_escape_string_quote(H->server, quoted + 2, ZSTR_VAL(unquoted), ZSTR_LEN(unquoted), '\'');
|
||||||
|
@ -343,8 +343,8 @@ static zend_string* mysql_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquo
|
||||||
quoted[++quotedlen] = '\0';
|
quoted[++quotedlen] = '\0';
|
||||||
PDO_DBG_INF_FMT("quoted=%.*s", (int)quotedlen, quoted);
|
PDO_DBG_INF_FMT("quoted=%.*s", (int)quotedlen, quoted);
|
||||||
|
|
||||||
quoted_str = zend_string_init(quoted, quotedlen, 0);
|
quoted_str = zend_string_truncate(quoted_str, quotedlen, false);
|
||||||
efree(quoted);
|
|
||||||
PDO_DBG_RETURN(quoted_str);
|
PDO_DBG_RETURN(quoted_str);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue