summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Beccati <mbeccati@php.net>2013-08-21 11:24:27 +0200
committerMatteo Beccati <mbeccati@php.net>2013-08-21 11:24:27 +0200
commit4283f75c347a105e53ae38fc96e614671df53f1b (patch)
treec3f345fb2e95e71b6b1e3bc9e6be8fc023da10b5
parent7be3c743392fbf1837760393403c7b703e502d3a (diff)
parent540f325664a6f4975cf005f367c95ece04757714 (diff)
downloadphp-git-4283f75c347a105e53ae38fc96e614671df53f1b.tar.gz
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: Fixed compiler warnings in ext/pgsql Fixed other compiler warnings in PDO_PGSQL Fixed compiler warning
-rw-r--r--ext/pdo/php_pdo_driver.h8
-rw-r--r--ext/pdo_pgsql/pgsql_driver.c8
-rw-r--r--ext/pdo_pgsql/pgsql_statement.c2
-rw-r--r--ext/pgsql/pgsql.c41
4 files changed, 34 insertions, 25 deletions
diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h
index c757dbf1e5..ede2d6fb76 100644
--- a/ext/pdo/php_pdo_driver.h
+++ b/ext/pdo/php_pdo_driver.h
@@ -72,11 +72,11 @@ enum pdo_param_type {
/* get_col ptr should point to a zval*
and the driver is responsible for adding correct type information to get_column_meta()
*/
- PDO_PARAM_ZVAL
-};
+ PDO_PARAM_ZVAL,
-/* magic flag to denote a parameter as being input/output */
-#define PDO_PARAM_INPUT_OUTPUT 0x80000000
+ /* magic flag to denote a parameter as being input/output */
+ PDO_PARAM_INPUT_OUTPUT = 0x80000000
+};
#define PDO_PARAM_FLAGS 0xFFFF0000
diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c
index 252bfff25b..50136430a0 100644
--- a/ext/pdo_pgsql/pgsql_driver.c
+++ b/ext/pdo_pgsql/pgsql_driver.c
@@ -315,9 +315,9 @@ static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote
case PDO_PARAM_LOB:
/* escapedlen returned by PQescapeBytea() accounts for trailing 0 */
#ifdef HAVE_PQESCAPE_BYTEA_CONN
- escaped = PQescapeByteaConn(H->server, unquoted, unquotedlen, &tmp_len);
+ escaped = PQescapeByteaConn(H->server, (unsigned char *)unquoted, (size_t)unquotedlen, &tmp_len);
#else
- escaped = PQescapeBytea(unquoted, unquotedlen, &tmp_len);
+ escaped = PQescapeBytea((unsigned char *)unquoted, (size_t)unquotedlen, &tmp_len);
#endif
*quotedlen = (int)tmp_len + 1;
*quoted = emalloc(*quotedlen + 1);
@@ -331,9 +331,9 @@ static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote
*quoted = safe_emalloc(2, unquotedlen, 3);
(*quoted)[0] = '\'';
#ifndef HAVE_PQESCAPE_CONN
- *quotedlen = PQescapeString(*quoted + 1, unquoted, unquotedlen);
+ *quotedlen = PQescapeString(*quoted + 1, unquoted, (size_t)unquotedlen);
#else
- *quotedlen = PQescapeStringConn(H->server, *quoted + 1, unquoted, unquotedlen, NULL);
+ *quotedlen = PQescapeStringConn(H->server, *quoted + 1, unquoted, (size_t)unquotedlen, NULL);
#endif
(*quoted)[*quotedlen + 1] = '\'';
(*quoted)[*quotedlen + 2] = '\0';
diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c
index 3ef89196de..792ad27078 100644
--- a/ext/pdo_pgsql/pgsql_statement.c
+++ b/ext/pdo_pgsql/pgsql_statement.c
@@ -536,7 +536,7 @@ static int pgsql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned
*len = 0;
return 0;
} else {
- char *tmp_ptr = PQunescapeBytea(*ptr, &tmp_len);
+ char *tmp_ptr = (char *)PQunescapeBytea((unsigned char *)*ptr, &tmp_len);
if (!tmp_ptr) {
/* PQunescapeBytea returned an error */
*len = 0;
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index f0e1780a79..2670914b78 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -4152,7 +4152,7 @@ PHP_FUNCTION(pg_escape_bytea)
#ifdef HAVE_PQESCAPE_BYTEA_CONN
if (pgsql_link != NULL || id != -1) {
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
- to = (char *)PQescapeByteaConn(pgsql, from, (size_t)from_len, &to_len);
+ to = (char *)PQescapeByteaConn(pgsql, (unsigned char *)from, (size_t)from_len, &to_len);
} else
#endif
to = (char *)PQescapeBytea((unsigned char*)from, from_len, &to_len);
@@ -4347,7 +4347,7 @@ static char* php_pgsql_PQescapeInternal(PGconn *conn, const char *str, size_t le
#endif
static void php_pgsql_escape_internal(INTERNAL_FUNCTION_PARAMETERS, int escape_literal) {
- char *from = NULL, *to = NULL, *tmp = NULL;
+ char *from = NULL, *to = NULL;
zval *pgsql_link = NULL;
PGconn *pgsql;
int from_len;
@@ -4380,17 +4380,22 @@ static void php_pgsql_escape_internal(INTERNAL_FUNCTION_PARAMETERS, int escape_l
RETURN_FALSE;
}
#ifdef HAVE_PQESCAPELITERAL
- if (escape_literal) {
- tmp = PQescapeLiteral(pgsql, from, (size_t)from_len);
- } else {
- tmp = PQescapeIdentifier(pgsql, from, (size_t)from_len);
- }
- if (!tmp) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Failed to escape");
- RETURN_FALSE;
+ /* Use a block with a local var to avoid unused variable warnings */
+ {
+ char *tmp;
+
+ if (escape_literal) {
+ tmp = PQescapeLiteral(pgsql, from, (size_t)from_len);
+ } else {
+ tmp = PQescapeIdentifier(pgsql, from, (size_t)from_len);
+ }
+ if (!tmp) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Failed to escape");
+ RETURN_FALSE;
+ }
+ to = estrdup(tmp);
+ PQfreemem(tmp);
}
- to = estrdup(tmp);
- PQfreemem(tmp);
#else
to = php_pgsql_PQescapeInternal(pgsql, from, (size_t)from_len, escape_literal);
if (!to) {
@@ -5121,7 +5126,9 @@ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, z
#else
new_len = PQescapeString(escaped, tmp_name2, strlen(tmp_name2));
#endif
- smart_str_appends(&querystr, escaped);
+ if (new_len) {
+ smart_str_appends(&querystr, escaped);
+ }
efree(escaped);
smart_str_appends(&querystr, "' AND c.relnamespace = n.oid AND n.nspname = '");
@@ -5131,7 +5138,9 @@ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, z
#else
new_len = PQescapeString(escaped, tmp_name, strlen(tmp_name));
#endif
- smart_str_appends(&querystr, escaped);
+ if (new_len) {
+ smart_str_appends(&querystr, escaped);
+ }
efree(escaped);
smart_str_appends(&querystr, "' AND a.atttypid = t.oid ORDER BY a.attnum;");
@@ -5924,9 +5933,9 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
size_t to_len;
smart_str s = {0};
#ifdef HAVE_PQESCAPE_BYTEA_CONN
- tmp = PQescapeByteaConn(pg_link, Z_STRVAL_PP(val), Z_STRLEN_PP(val), &to_len);
+ tmp = PQescapeByteaConn(pg_link, (unsigned char *)Z_STRVAL_PP(val), Z_STRLEN_PP(val), &to_len);
#else
- tmp = PQescapeBytea(Z_STRVAL_PP(val), Z_STRLEN_PP(val), &to_len);
+ tmp = PQescapeBytea(Z_STRVAL_PP(val), (unsigned char *)Z_STRLEN_PP(val), &to_len);
#endif
Z_TYPE_P(new_val) = IS_STRING;
Z_STRLEN_P(new_val) = to_len-1; /* PQescapeBytea's to_len includes additional '\0' */