Replace sprintf with snprintf (#1758)

Co-authored-by: francesco.laplaca <francesco.laplaca@enhancers.it>
Co-authored-by: Ken Matsui <26405363+ken-matsui@users.noreply.github.com>
This commit is contained in:
frank10gm 2023-08-28 11:18:12 +02:00 committed by GitHub
parent 40aa034595
commit 816684e15d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 9 deletions

View File

@ -508,7 +508,7 @@ if(@@.get<std::string>("rdbms")=="postgresql")
if(@@.get<std::string>("rdbms")=="postgresql")
{
%>
n = sprintf(placeholderStr,"$%d,",placeholder++);
n = snprintf(placeholderStr,sizeof(placeholderStr),"$%d,",placeholder++);
sql.append(placeholderStr, n);
<%c++
}else

View File

@ -352,43 +352,67 @@ class Users
size_t n = 0;
if (dirtyFlag_[0])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
if (dirtyFlag_[1])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
if (dirtyFlag_[2])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
if (dirtyFlag_[3])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
if (dirtyFlag_[4])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
if (dirtyFlag_[5])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
sql += "default,";
if (dirtyFlag_[7])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
if (dirtyFlag_[8])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
else