mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-29 20:59:45 +01:00
fix(SQLite): SQLite::Connector::open() crashes on db file with non existing directory #2285
This commit is contained in:
@@ -176,6 +176,8 @@ void SessionImpl::open(const std::string& connect)
|
|||||||
rc = sqlite3_open_v2(connectionString().c_str(), &_pDB,
|
rc = sqlite3_open_v2(connectionString().c_str(), &_pDB,
|
||||||
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI, NULL);
|
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI, NULL);
|
||||||
if (rc == SQLITE_OK) break;
|
if (rc == SQLITE_OK) break;
|
||||||
|
if (!_pDB)
|
||||||
|
throw ConnectionFailedException(std::string(sqlite3_errstr(rc)));
|
||||||
if (sw.elapsedSeconds() >= tout)
|
if (sw.elapsedSeconds() >= tout)
|
||||||
{
|
{
|
||||||
Utility::throwException(_pDB, rc);
|
Utility::throwException(_pDB, rc);
|
||||||
|
|||||||
@@ -1376,6 +1376,21 @@ void SQLiteTest::testEmptyDB()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SQLiteTest::testNonexistingDB()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Session tmp (Poco::Data::SQLite::Connector::KEY, "foo/bar/nonexisting.db", 1);
|
||||||
|
fail("non-existing DB must throw");
|
||||||
|
}
|
||||||
|
catch(ConnectionFailedException& ex)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fail("non-existing DB must throw ConnectionFailedException");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SQLiteTest::testCLOB()
|
void SQLiteTest::testCLOB()
|
||||||
{
|
{
|
||||||
std::string lastName("lastname");
|
std::string lastName("lastname");
|
||||||
@@ -3506,6 +3521,7 @@ CppUnit::Test* SQLiteTest::suite()
|
|||||||
CppUnit_addTest(pSuite, SQLiteTest, testIllegalRange);
|
CppUnit_addTest(pSuite, SQLiteTest, testIllegalRange);
|
||||||
CppUnit_addTest(pSuite, SQLiteTest, testSingleSelect);
|
CppUnit_addTest(pSuite, SQLiteTest, testSingleSelect);
|
||||||
CppUnit_addTest(pSuite, SQLiteTest, testEmptyDB);
|
CppUnit_addTest(pSuite, SQLiteTest, testEmptyDB);
|
||||||
|
CppUnit_addTest(pSuite, SQLiteTest, testNonexistingDB);
|
||||||
CppUnit_addTest(pSuite, SQLiteTest, testCLOB);
|
CppUnit_addTest(pSuite, SQLiteTest, testCLOB);
|
||||||
CppUnit_addTest(pSuite, SQLiteTest, testBLOB);
|
CppUnit_addTest(pSuite, SQLiteTest, testBLOB);
|
||||||
CppUnit_addTest(pSuite, SQLiteTest, testTuple10);
|
CppUnit_addTest(pSuite, SQLiteTest, testTuple10);
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ public:
|
|||||||
void testIllegalRange();
|
void testIllegalRange();
|
||||||
void testSingleSelect();
|
void testSingleSelect();
|
||||||
void testEmptyDB();
|
void testEmptyDB();
|
||||||
|
void testNonexistingDB();
|
||||||
|
|
||||||
void testCLOB();
|
void testCLOB();
|
||||||
void testBLOB();
|
void testBLOB();
|
||||||
|
|||||||
Reference in New Issue
Block a user