Add missing buffer size check to SQLite QuoteString impl
This commit is contained in:
parent
1ff13c59cf
commit
7c3bcc9c25
@ -84,6 +84,18 @@ IDBDriver *SqDatabase::GetDriver()
|
|||||||
|
|
||||||
bool SqDatabase::QuoteString(const char *str, char buffer[], size_t maxlen, size_t *newSize)
|
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);
|
char *res = sqlite3_snprintf(static_cast<int>(maxlen), buffer, "%q", str);
|
||||||
|
|
||||||
if (res != NULL && newSize != NULL)
|
if (res != NULL && newSize != NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user