GH #3876: Replace sprintf with snprintf in Environment and NumberFormatter to avoid deprecation warnings

This commit is contained in:
Günter Obiltschnig
2022-11-17 11:41:41 +01:00
parent 5a252fddcb
commit 4e8837db9e
4 changed files with 9 additions and 13 deletions

View File

@@ -18,8 +18,8 @@
#include "Poco/Data/MySQL/MySQLException.h"
#include <mysql.h>
#include <stdio.h>
#include "Poco/NumberFormatter.h"
#include <mysql/mysql.h>
namespace Poco {
@@ -71,9 +71,7 @@ std::string ConnectionException::compose(const std::string& text, MYSQL* h)
str += mysql_error(h);
str += "\t[mysql_errno]: ";
char buff[30];
sprintf(buff, "%d", mysql_errno(h));
str += buff;
Poco::NumberFormatter::append(str, mysql_errno(h));
str += "\t[mysql_sqlstate]: ";
str += mysql_sqlstate(h);
@@ -125,9 +123,7 @@ std::string StatementException::compose(const std::string& text, MYSQL_STMT* h,
str += mysql_stmt_error(h);
str += "\t[mysql_stmt_errno]: ";
char buff[30];
sprintf(buff, "%d", mysql_stmt_errno(h));
str += buff;
Poco::NumberFormatter::append(str, mysql_stmt_errno(h));
str += "\t[mysql_stmt_sqlstate]: ";
str += mysql_stmt_sqlstate(h);