Add missing buffer size check to SQLite QuoteString implementation (#411)

This commit is contained in:
Vincent Herbet 2017-02-23 13:56:58 +01:00 committed by GitHub
parent 074af44ead
commit b973d24081

View File

@ -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)