Add missing buffer size check to SQLite QuoteString implementation (#411)
This commit is contained in:
parent
074af44ead
commit
b973d24081
@ -81,6 +81,14 @@ IQuery *SqliteDatabase::PrepareQueryFmt(const char *fmt, ...)
|
||||
|
||||
int SqliteDatabase::QuoteString(const char *str, char buffer[], size_t maxlen, size_t *newsize)
|
||||
{
|
||||
auto size = strlen(str);
|
||||
auto needed = size * 2 + 1;
|
||||
|
||||
if (maxlen < needed)
|
||||
{
|
||||
return static_cast<int>(needed);
|
||||
}
|
||||
|
||||
char *res = sqlite3_snprintf(static_cast<int>(maxlen), buffer, "%q", str);
|
||||
|
||||
if (res != NULL && newsize != NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user