Skip to content

Commit 764054c

Browse files
committed
Merge branch 'master' of https://github.com/php/php-src into string_size_refactor_take_2
2 parents 5c6428b + 9507fcf commit 764054c

File tree

10 files changed

+47
-41
lines changed

10 files changed

+47
-41
lines changed

ext/dom/php_dom.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,11 @@ void dom_xpath_objects_free_storage(void *object TSRMLS_DC)
10891089
void dom_objects_free_storage(void *object TSRMLS_DC)
10901090
{
10911091
dom_object *intern = (dom_object *)object;
1092+
#if defined(__GNUC__) && __GNUC__ >= 3
1093+
int retcount __attribute__((unused)); /* keep compiler quiet */
1094+
#else
10921095
int retcount;
1096+
#endif
10931097

10941098
zend_object_std_dtor(&intern->std TSRMLS_CC);
10951099

ext/intl/intl_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ typedef struct _intl_data {
7979
int u8len; \
8080
intl_convert_utf16_to_utf8(&u8value, &u8len, ustring, ulen, &INTL_DATA_ERROR_CODE((obj))); \
8181
if((free_it)) { \
82-
efree(ustring); \
82+
efree((void *)ustring); \
8383
} \
8484
INTL_METHOD_CHECK_STATUS((obj), "Error converting value to UTF-8"); \
8585
RETVAL_STRINGL(u8value, u8len, 0); \

ext/pdo/php_pdo_driver.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ enum pdo_param_type {
7272
/* get_col ptr should point to a zval*
7373
and the driver is responsible for adding correct type information to get_column_meta()
7474
*/
75-
PDO_PARAM_ZVAL
76-
};
75+
PDO_PARAM_ZVAL,
7776

78-
/* magic flag to denote a parameter as being input/output */
79-
#define PDO_PARAM_INPUT_OUTPUT 0x80000000
77+
/* magic flag to denote a parameter as being input/output */
78+
PDO_PARAM_INPUT_OUTPUT = 0x80000000
79+
};
8080

8181
#define PDO_PARAM_FLAGS 0xFFFF0000
8282

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,9 @@ static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote
320320
case PDO_PARAM_LOB:
321321
/* escapedlen returned by PQescapeBytea() accounts for trailing 0 */
322322
#ifdef HAVE_PQESCAPE_BYTEA_CONN
323-
escaped = PQescapeByteaConn(H->server, (unsigned char *)unquoted, unquotedlen, &tmp_len);
323+
escaped = PQescapeByteaConn(H->server, (unsigned char *)unquoted, (size_t)unquotedlen, &tmp_len);
324324
#else
325-
escaped = PQescapeBytea(unquoted, unquotedlen, &tmp_len);
325+
escaped = PQescapeBytea((unsigned char *)unquoted, (size_t)unquotedlen, &tmp_len);
326326
#endif
327327
*quotedlen = (int)tmp_len + 1;
328328
*quoted = emalloc(*quotedlen + 1);
@@ -336,9 +336,9 @@ static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote
336336
*quoted = safe_emalloc(2, unquotedlen, 3);
337337
(*quoted)[0] = '\'';
338338
#ifndef HAVE_PQESCAPE_CONN
339-
*quotedlen = PQescapeString(*quoted + 1, unquoted, unquotedlen);
339+
*quotedlen = PQescapeString(*quoted + 1, unquoted, (size_t)unquotedlen);
340340
#else
341-
*quotedlen = PQescapeStringConn(H->server, *quoted + 1, unquoted, unquotedlen, NULL);
341+
*quotedlen = PQescapeStringConn(H->server, *quoted + 1, unquoted, (size_t)unquotedlen, NULL);
342342
#endif
343343
(*quoted)[*quotedlen + 1] = '\'';
344344
(*quoted)[*quotedlen + 2] = '\0';

ext/pdo_pgsql/pgsql_statement.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ static int pgsql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned
536536
*len = 0;
537537
return 0;
538538
} else {
539-
char *tmp_ptr = PQunescapeBytea(*ptr, &tmp_len);
539+
char *tmp_ptr = (char *)PQunescapeBytea((unsigned char *)*ptr, &tmp_len);
540540
if (!tmp_ptr) {
541541
/* PQunescapeBytea returned an error */
542542
*len = 0;

ext/pgsql/pgsql.c

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4152,7 +4152,7 @@ PHP_FUNCTION(pg_escape_bytea)
41524152
#ifdef HAVE_PQESCAPE_BYTEA_CONN
41534153
if (pgsql_link != NULL || id != -1) {
41544154
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
4155-
to = (char *)PQescapeByteaConn(pgsql, from, (size_t)from_len, &to_len);
4155+
to = (char *)PQescapeByteaConn(pgsql, (unsigned char *)from, (size_t)from_len, &to_len);
41564156
} else
41574157
#endif
41584158
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
43474347
#endif
43484348

43494349
static void php_pgsql_escape_internal(INTERNAL_FUNCTION_PARAMETERS, int escape_literal) {
4350-
char *from = NULL, *to = NULL, *tmp = NULL;
4350+
char *from = NULL, *to = NULL;
43514351
zval *pgsql_link = NULL;
43524352
PGconn *pgsql;
43534353
int from_len;
@@ -4380,17 +4380,22 @@ static void php_pgsql_escape_internal(INTERNAL_FUNCTION_PARAMETERS, int escape_l
43804380
RETURN_FALSE;
43814381
}
43824382
#ifdef HAVE_PQESCAPELITERAL
4383-
if (escape_literal) {
4384-
tmp = PQescapeLiteral(pgsql, from, (size_t)from_len);
4385-
} else {
4386-
tmp = PQescapeIdentifier(pgsql, from, (size_t)from_len);
4387-
}
4388-
if (!tmp) {
4389-
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Failed to escape");
4390-
RETURN_FALSE;
4383+
/* Use a block with a local var to avoid unused variable warnings */
4384+
{
4385+
char *tmp;
4386+
4387+
if (escape_literal) {
4388+
tmp = PQescapeLiteral(pgsql, from, (size_t)from_len);
4389+
} else {
4390+
tmp = PQescapeIdentifier(pgsql, from, (size_t)from_len);
4391+
}
4392+
if (!tmp) {
4393+
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Failed to escape");
4394+
RETURN_FALSE;
4395+
}
4396+
to = estrdup(tmp);
4397+
PQfreemem(tmp);
43914398
}
4392-
to = estrdup(tmp);
4393-
PQfreemem(tmp);
43944399
#else
43954400
to = php_pgsql_PQescapeInternal(pgsql, from, (size_t)from_len, escape_literal);
43964401
if (!to) {
@@ -5121,7 +5126,9 @@ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, z
51215126
#else
51225127
new_len = PQescapeString(escaped, tmp_name2, strlen(tmp_name2));
51235128
#endif
5124-
smart_str_appends(&querystr, escaped);
5129+
if (new_len) {
5130+
smart_str_appends(&querystr, escaped);
5131+
}
51255132
efree(escaped);
51265133

51275134
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
51315138
#else
51325139
new_len = PQescapeString(escaped, tmp_name, strlen(tmp_name));
51335140
#endif
5134-
smart_str_appends(&querystr, escaped);
5141+
if (new_len) {
5142+
smart_str_appends(&querystr, escaped);
5143+
}
51355144
efree(escaped);
51365145

51375146
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
59245933
size_t to_len;
59255934
smart_str s = {0};
59265935
#ifdef HAVE_PQESCAPE_BYTEA_CONN
5927-
tmp = PQescapeByteaConn(pg_link, Z_STRVAL_PP(val), Z_STRLEN_PP(val), &to_len);
5936+
tmp = PQescapeByteaConn(pg_link, (unsigned char *)Z_STRVAL_PP(val), Z_STRLEN_PP(val), &to_len);
59285937
#else
5929-
tmp = PQescapeBytea(Z_STRVAL_PP(val), Z_STRLEN_PP(val), &to_len);
5938+
tmp = PQescapeBytea(Z_STRVAL_PP(val), (unsigned char *)Z_STRLEN_PP(val), &to_len);
59305939
#endif
59315940
Z_TYPE_P(new_val) = IS_STRING;
59325941
Z_STRLEN_P(new_val) = to_len-1; /* PQescapeBytea's to_len includes additional '\0' */

ext/session/mod_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ PS_CREATE_SID_FUNC(user)
188188
/* maintain backwards compatibility */
189189
if (PSF(create_sid) != NULL) {
190190
char *id = NULL;
191-
STDVARS;
191+
zval *retval = NULL;
192192

193193
retval = ps_call_handler(PSF(create_sid), 0, NULL TSRMLS_CC);
194194

ext/session/session.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -853,9 +853,6 @@ PS_SERIALIZER_ENCODE_FUNC(php_serialize) /* {{{ */
853853
{
854854
smart_str buf = {0};
855855
php_serialize_data_t var_hash;
856-
HashTable *_ht = Z_ARRVAL_P(PS(http_session_vars));
857-
int key_type;
858-
PS_ENCODE_VARS;
859856

860857
PHP_VAR_SERIALIZE_INIT(var_hash);
861858
php_var_serialize(&buf, &PS(http_session_vars), &var_hash TSRMLS_CC);
@@ -871,12 +868,8 @@ PS_SERIALIZER_ENCODE_FUNC(php_serialize) /* {{{ */
871868

872869
PS_SERIALIZER_DECODE_FUNC(php_serialize) /* {{{ */
873870
{
874-
const char *p;
875-
char *name;
876871
const char *endptr = val + vallen;
877872
zval *session_vars;
878-
int namelen;
879-
int has_value;
880873
php_unserialize_data_t var_hash;
881874

882875
PHP_VAR_UNSERIALIZE_INIT(var_hash);

ext/standard/info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ void php_info_print_style(TSRMLS_D)
287287
PHPAPI char *php_info_html_esc(char *string TSRMLS_DC)
288288
{
289289
size_t new_len;
290-
return php_escape_html_entities(string, strlen(string), &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
290+
return php_escape_html_entities((unsigned char *) string, strlen(string), &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
291291
}
292292
/* }}} */
293293

ext/standard/password.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,20 @@ static php_password_algo php_password_determine_algo(const char *hash, const siz
6666
return PHP_PASSWORD_UNKNOWN;
6767
}
6868

69-
static zend_bool php_password_salt_is_alphabet(const char *str, const size_t len) /* {{{ */
69+
static int php_password_salt_is_alphabet(const char *str, const size_t len) /* {{{ */
7070
{
7171
size_t i = 0;
7272

7373
for (i = 0; i < len; i++) {
7474
if (!((str[i] >= 'A' && str[i] <= 'Z') || (str[i] >= 'a' && str[i] <= 'z') || (str[i] >= '0' && str[i] <= '9') || str[i] == '.' || str[i] == '/')) {
75-
return 0;
75+
return FAILURE;
7676
}
7777
}
78-
return 1;
78+
return SUCCESS;
7979
}
8080
/* }}} */
8181

82-
static zend_bool php_password_salt_to64(const char *str, const size_t str_len, const size_t out_len, char *ret) /* {{{ */
82+
static int php_password_salt_to64(const char *str, const size_t str_len, const size_t out_len, char *ret) /* {{{ */
8383
{
8484
size_t pos = 0;
8585
size_t ret_len = 0;
@@ -108,7 +108,7 @@ static zend_bool php_password_salt_to64(const char *str, const size_t str_len, c
108108
}
109109
/* }}} */
110110

111-
static zend_bool php_password_make_salt(size_t length, char *ret TSRMLS_DC) /* {{{ */
111+
static int php_password_make_salt(size_t length, char *ret TSRMLS_DC) /* {{{ */
112112
{
113113
int buffer_valid = 0;
114114
size_t i, raw_length;
@@ -395,7 +395,7 @@ PHP_FUNCTION(password_hash)
395395
efree(buffer);
396396
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Provided salt is too short: %lu expecting %lu", (unsigned long) buffer_len, (unsigned long) required_salt_len);
397397
RETURN_NULL();
398-
} else if (0 == php_password_salt_is_alphabet(buffer, buffer_len)) {
398+
} else if (php_password_salt_is_alphabet(buffer, buffer_len) == FAILURE) {
399399
salt = safe_emalloc(required_salt_len, 1, 1);
400400
if (php_password_salt_to64(buffer, buffer_len, required_salt_len, salt) == FAILURE) {
401401
efree(hash_format);

0 commit comments

Comments
 (0)