From 1651c61ca217ec1256b0c71d4c9fb5ffb496d0e5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 15 Dec 2009 12:46:23 +0100 Subject: SQLite3: log db filename on open error Signed-off-by: Denys Vlasenko --- lib/Plugins/SQLite3.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Plugins/SQLite3.cpp') diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp index d95c273..c3f7a7d 100644 --- a/lib/Plugins/SQLite3.cpp +++ b/lib/Plugins/SQLite3.cpp @@ -262,7 +262,7 @@ void CSQLite3::Connect() { if (ret != SQLITE_CANTOPEN) { - throw CABRTException(EXCEP_PLUGIN, "Can't open database: %s", sqlite3_errmsg(m_pDB)); + throw CABRTException(EXCEP_PLUGIN, "Can't open database '%s': %s", m_sDBPath.c_str(), sqlite3_errmsg(m_pDB)); } ret = sqlite3_open_v2(m_sDBPath.c_str(), @@ -272,7 +272,7 @@ void CSQLite3::Connect() ); if (ret != SQLITE_OK) { - throw CABRTException(EXCEP_PLUGIN, "Can't create database: %s", sqlite3_errmsg(m_pDB)); + throw CABRTException(EXCEP_PLUGIN, "Can't create database '%s': %s", m_sDBPath.c_str(), sqlite3_errmsg(m_pDB)); } } -- cgit From 1e119f37b85b90c5a9a17fdcbc80625727b4ab66 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 15 Dec 2009 19:54:51 +0100 Subject: fix all instances of atoi() usage Signed-off-by: Denys Vlasenko --- lib/Plugins/SQLite3.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Plugins/SQLite3.cpp') diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp index c3f7a7d..12f8a5d 100644 --- a/lib/Plugins/SQLite3.cpp +++ b/lib/Plugins/SQLite3.cpp @@ -198,9 +198,9 @@ static bool check_table(sqlite3 *db) if (pos != string::npos) { string tableVersion = tableName.substr(pos + 2); - if (atoi(tableVersion.c_str()) < ABRT_TABLE_VERSION) + if (xatoi_u(tableVersion.c_str()) < ABRT_TABLE_VERSION) { - update_from_old_ver(db, atoi(tableVersion.c_str())); + update_from_old_ver(db, xatoi_u(tableVersion.c_str())); } return true; } -- cgit From 707f64b85c8a1b88923617ff72bd8a4ca562f3bd Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 16 Dec 2009 15:09:55 +0100 Subject: prevent destructors from throwing exceptions; check curl_easy_init errors Signed-off-by: Denys Vlasenko --- lib/Plugins/SQLite3.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/Plugins/SQLite3.cpp') diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp index 12f8a5d..1979f24 100644 --- a/lib/Plugins/SQLite3.cpp +++ b/lib/Plugins/SQLite3.cpp @@ -238,7 +238,18 @@ CSQLite3::CSQLite3() : CSQLite3::~CSQLite3() { - DisConnect(); + /* Paranoia. In C++, destructor will abort() if it was called while unwinding + * the stack and it throws an exception. + */ + try + { + DisConnect(); + m_sDBPath.clear(); + } + catch (...) + { + error_msg_and_die("Internal error"); + } } void CSQLite3::DisConnect() -- cgit