summaryrefslogtreecommitdiff
path: root/ext/mysql/php_mysql.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mysql/php_mysql.c')
-rw-r--r--ext/mysql/php_mysql.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index e884747127..91df858c96 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -447,9 +447,9 @@ PHP_MINFO_FUNCTION(mysql)
php_info_print_table_start();
php_info_print_table_header(2, "MySQL Support", "enabled");
- sprintf(buf, "%ld", MySG(num_persistent));
+ snprintf(buf, sizeof(buf), "%ld", MySG(num_persistent));
php_info_print_table_row(2, "Active Persistent Links", buf);
- sprintf(buf, "%ld", MySG(num_links));
+ snprintf(buf, sizeof(buf), "%ld", MySG(num_links));
php_info_print_table_row(2, "Active Links", buf);
php_info_print_table_row(2, "Client API version", mysql_get_client_info());
#if !defined (PHP_WIN32) && !defined (NETWARE)
@@ -519,9 +519,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
host_and_port=passwd=NULL;
user=php_get_current_user();
- hashed_details_length = strlen(user)+5+3;
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details, "mysql__%s_", user);
+ hashed_details_length = spprintf(&hashed_details, 0, "mysql__%s_", user);
client_flags = CLIENT_INTERACTIVE;
} else {
host_and_port = MySG(default_host);
@@ -617,9 +615,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
}
- hashed_details_length = sizeof("mysql___")-1 + strlen(SAFE_STRING(host_and_port))+strlen(SAFE_STRING(user))+strlen(SAFE_STRING(passwd));
- hashed_details = (char *) emalloc(hashed_details_length+1);
- sprintf(hashed_details, "mysql_%s_%s_%s", SAFE_STRING(host_and_port), SAFE_STRING(user), SAFE_STRING(passwd));
+ hashed_details_length = spprintf(&hashed_details, 0, "mysql_%s_%s_%s", SAFE_STRING(host_and_port), SAFE_STRING(user), SAFE_STRING(passwd));
}
/* We cannot use mysql_port anymore in windows, need to use
@@ -1235,9 +1231,9 @@ static void php_mysql_do_query_general(zval **query, zval **mysql_link, int link
if (!strncasecmp("select", Z_STRVAL_PP(query), 6)){
MYSQL_ROW row;
- char *newquery = (char *)emalloc(Z_STRLEN_PP(query) + 10);
- sprintf ((char *)newquery, "EXPLAIN %s", Z_STRVAL_PP(query));
- mysql_real_query(&mysql->conn, newquery, strlen(newquery));
+ char *newquery;
+ int newql = spprintf (&newquery, 0, "EXPLAIN %s", Z_STRVAL_PP(query));
+ mysql_real_query(&mysql->conn, newquery, newql);
efree (newquery);
if (mysql_errno(&mysql->conn)) {
php_error_docref("http://www.mysql.com/doc" TSRMLS_CC, E_WARNING, "%s", mysql_error(&mysql->conn));