Add missing buffer size check to SQLite QuoteString impl

This commit is contained in:
Asher Baker 2016-02-15 14:19:11 +00:00
parent 1ff13c59cf
commit 7c3bcc9c25

View File

@ -84,6 +84,18 @@ IDBDriver *SqDatabase::GetDriver()
bool SqDatabase::QuoteString(const char *str, char buffer[], size_t maxlen, size_t *newSize)
{
unsigned long size = static_cast<unsigned long>(strlen(str));
unsigned long needed = size * 2 + 1;
if (maxlen < needed)
{
if (newSize != NULL)
{
*newSize = (size_t)needed;
}
return false;
}
char *res = sqlite3_snprintf(static_cast<int>(maxlen), buffer, "%q", str);
if (res != NULL && newSize != NULL)