summaryrefslogtreecommitdiff
path: root/ext/pdo_pgsql
diff options
context:
space:
mode:
authorEdin Kadribasic <edink@php.net>2005-01-17 10:37:41 +0000
committerEdin Kadribasic <edink@php.net>2005-01-17 10:37:41 +0000
commit095a6f1eb34f764646f84e8089463bcb7a72069b (patch)
tree094913759a6bf4e8f8805cc94b9e312efba50617 /ext/pdo_pgsql
parent3a751f37c661f05b93d949806e2f67a352e2ba73 (diff)
downloadphp-git-095a6f1eb34f764646f84e8089463bcb7a72069b.tar.gz
Use PQescapeBytea() for quoting. Need to think how to add binary safe
quoting for blobls (pgsql bytea type). Fixes #2818
Diffstat (limited to 'ext/pdo_pgsql')
-rw-r--r--ext/pdo_pgsql/pgsql_driver.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c
index f0815cbada..e60fbc1f87 100644
--- a/ext/pdo_pgsql/pgsql_driver.c
+++ b/ext/pdo_pgsql/pgsql_driver.c
@@ -175,18 +175,12 @@ static long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRM
static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen TSRMLS_DC)
{
- unsigned char *escaped;
-
- /* escapedlen returned by PQescapeBytea() accounts for trailing 0 */
- escaped = PQescapeBytea(unquoted, unquotedlen, quotedlen);
- *quotedlen += 1;
- *quoted = emalloc(*quotedlen + 1);
- memcpy((*quoted)+1, escaped, *quotedlen-2);
+ *quoted = emalloc(2*unquotedlen + 3);
(*quoted)[0] = '\'';
- (*quoted)[*quotedlen-1] = '\'';
- (*quoted)[*quotedlen] = '\0';
- free(escaped);
-
+ *quotedlen = PQescapeString(*quoted + 1, unquoted, unquotedlen);
+ (*quoted)[*quotedlen + 1] = '\'';
+ (*quoted)[*quotedlen + 2] = '\0';
+ *quotedlen += 2;
return 1;
}