diff --git a/bindings/java/jni/dataModel_SleuthkitJNI.cpp b/bindings/java/jni/dataModel_SleuthkitJNI.cpp index 7b1d4d4cb69c1cc2d0fbecc1d3a7767e36515f80..0bbb13e4ae43257f2cbbfdf5f41faa7cfbd28053 100644 --- a/bindings/java/jni/dataModel_SleuthkitJNI.cpp +++ b/bindings/java/jni/dataModel_SleuthkitJNI.cpp @@ -248,6 +248,65 @@ JNIEXPORT jlong JNICALL } +/* + * Open a TskCaseDb with an associated database + * @return the pointer to the case + * @param env pointer to java environment this was called from + * @param dbPath location for the database + * @return 0 on error (sets java exception), pointer to newly opened TskCaseDb object on success + */ +JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_newCaseDbMultiNat(JNIEnv *env, jclass cls, jstring host, jstring port, jstring user, jstring pass, jint asdf, jstring dbName) //jobject dbType, jstring dbName) +{ + TSK_TCHAR dbPathT[1024]; + toTCHAR(env, dbPathT, 1024, dbName); + + CaseDbConnectionInfo info(env->GetStringUTFChars(host, false), + env->GetStringUTFChars(port, false), + env->GetStringUTFChars(user, false), + env->GetStringUTFChars(pass, false), + CaseDbConnectionInfo::POSTGRESQL); + + TskCaseDb *tskCase = TskCaseDb::newDb(dbPathT, &info); + + if (tskCase == NULL) { + setThrowTskCoreError(env); + return 0; + } + + return (jlong) tskCase; +} + + +/* + * Open a TskCaseDb with an associated database + * @return the pointer to the case + * @param env pointer to java environment this was called from + * @param dbPath location for the database + * @return Returns pointer to object or exception on error + */ +JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_openCaseDbMultiNat(JNIEnv *env, jclass cls, jstring host, jstring port, jstring user, jstring pass, jint asdf, jstring dbName) //jobject dbType, jstring dbName) +{ + TSK_TCHAR dbPathT[1024]; + toTCHAR(env, dbPathT, 1024, dbName); + + CaseDbConnectionInfo info(env->GetStringUTFChars(host, false), + env->GetStringUTFChars(port, false), + env->GetStringUTFChars(user, false), + env->GetStringUTFChars(pass, false), + CaseDbConnectionInfo::POSTGRESQL); + + TskCaseDb *tskCase = TskCaseDb::openDb(dbPathT, &info); + + if (tskCase == NULL) { + setThrowTskCoreError(env); + return 0; + } + + return (jlong) tskCase; +} + + + /* * Open a TskCaseDb with an associated database * @return the pointer to the case @@ -272,6 +331,7 @@ JNIEXPORT jlong JNICALL return (jlong) tskCase; } + /* * Close (cleanup) a case * @param env pointer to java environment this was called from diff --git a/bindings/java/jni/dataModel_SleuthkitJNI.h b/bindings/java/jni/dataModel_SleuthkitJNI.h index 3daa672b8c11c4e0e66c670e30ac067ad51dccff..53c804f6ee7b060d5121be6c320a9be42406d446 100644 --- a/bindings/java/jni/dataModel_SleuthkitJNI.h +++ b/bindings/java/jni/dataModel_SleuthkitJNI.h @@ -33,6 +33,22 @@ JNIEXPORT void JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_startVerboseLog JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_newCaseDbNat (JNIEnv *, jclass, jstring); +/* + * Class: org_sleuthkit_datamodel_SleuthkitJNI + * Method: newCaseDbMultiNat + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_newCaseDbMultiNat + (JNIEnv *env, jclass cls, jstring host, jstring port, jstring user, jstring pass, jint asdf, jstring dbName); + +/* + * Class: org_sleuthkit_datamodel_SleuthkitJNI + * Method: openCaseDbMultiNat + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_openCaseDbMultiNat + (JNIEnv *, jclass, jstring, jstring, jstring, jstring, jint, jstring); + /* * Class: org_sleuthkit_datamodel_SleuthkitJNI * Method: openCaseDbNat diff --git a/tsk/auto/Makefile.am b/tsk/auto/Makefile.am index 8276c3f9b0ae9153f6201f158b7a3cea21e6f12c..ef9d9991c5ec98242926aaaad10b3b45ef3a4bf6 100755 --- a/tsk/auto/Makefile.am +++ b/tsk/auto/Makefile.am @@ -3,7 +3,7 @@ EXTRA_DIST = .indent.pro noinst_LTLIBRARIES = libtskauto.la # Note that the .h files are in the top-level Makefile -libtskauto_la_SOURCES = auto.cpp auto_db.cpp sqlite3.c sqlite3.h db_sqlite.cpp case_db.cpp tsk_case_db.h tsk_db.cpp tsk_auto.h tsk_auto_i.h tsk_case_db.h tsk_db.h tsk_db_sqlite.h +libtskauto_la_SOURCES = db_connection_info.h auto.cpp auto_db.cpp sqlite3.c sqlite3.h db_sqlite.cpp case_db.cpp tsk_case_db.h tsk_db.cpp tsk_auto.h tsk_auto_i.h tsk_case_db.h tsk_db.h tsk_db_sqlite.h indent: indent *.cpp *.h diff --git a/tsk/auto/case_db.cpp b/tsk/auto/case_db.cpp index e1a6803b05c3c6908c1f614c38aefc9bc25cd213..8609b8159320e5a4356397c12b9adaca25cdfc0e 100644 --- a/tsk/auto/case_db.cpp +++ b/tsk/auto/case_db.cpp @@ -45,24 +45,54 @@ TskCaseDb::~TskCaseDb() } /** -* Creates a new case with a new database and initializes its tables. -* Fails if there's already a file at the given path. Returns a pointer -* to a new TskCaseDb if successful, else NULL. +* Creates a new single-user case with a new database and initializes its tables. +* Fails if there's already a file at the given path. * * @param path Full path to create new database at. +* @returns Pointer to a new TskCaseDb object, NULL on error */ TskCaseDb * TskCaseDb::newDb(const TSK_TCHAR * const path) { + TskDb *db = new TskDbSqlite(path, true); -#if defined(HAVE_POSTGRESQL) && defined(TSK_WIN32) - // ELTODO: check here which database to initialize - //TskDb *db = new TskDbSqlite(path, true); + // Check if the database already exsists + if (db->dbExists()) { + tsk_error_reset(); + tsk_error_set_errno(TSK_ERR_AUTO_DB); + tsk_error_set_errstr("Database %" PRIttocTSK + " already exists. Must be deleted first.", path); + delete(db); + return NULL; + } + + // Open the database. + if (db->open(true)) { + delete(db); + return NULL; + } + + return new TskCaseDb(db); +} +/** +* Creates a new multi-user case with a new database and initializes its tables. +* Fails if multi-user database with requested name already exists. +* +* @param path Full path to create new database at. +* @returns Pointer to a new TskCaseDb object, NULL on error +*/ +TskCaseDb * +TskCaseDb::newDb(const TSK_TCHAR * const path, CaseDbConnectionInfo * info) +{ +#if defined(HAVE_POSTGRESQL) && defined(TSK_WIN32) TskDb *db = new TskDbPostgreSQL(path, true); -#else - TskDb *db = new TskDbSqlite(path, true); -#endif // HAVE_POSTGRESQL && TSK_WIN32 + + // Store connection info for the multi-user database + if (db->setConnectionInfo(info) != TSK_OK) { + delete(db); + return NULL; + } // Check if the database already exsists if (db->dbExists()) { @@ -81,25 +111,59 @@ TskCaseDb::newDb(const TSK_TCHAR * const path) } return new TskCaseDb(db); +#else + return NULL; +#endif // HAVE_POSTGRESQL && TSK_WIN32 } /** -* Opens a case from an existing database. +* Opens a single-user case from an existing database. * * @param path Full path to open database from. +* @returns Pointer to a new TskCaseDb object, NULL on error */ TskCaseDb * TskCaseDb::openDb(const TSK_TCHAR * path) { + TskDb *db = new TskDbSqlite(path, true); + + // Confirm that database already exsists + if (!db->dbExists()) { + tsk_error_reset(); + tsk_error_set_errno(TSK_ERR_AUTO_DB); + tsk_error_set_errstr("Database %" PRIttocTSK + " does not exist. Must be created first.", path); + delete(db); + return NULL; + } + // Open the database. + if (db->open(false)) { + delete(db); + return NULL; + } + + return new TskCaseDb(db); +} + +/** +* Opens a multi-user case from an existing database. +* +* @param CaseDbConnectionInfo object containing datbase connection info. +* @returns Pointer to a new TskCaseDb object, NULL on error +*/ +TskCaseDb * +TskCaseDb::openDb(const TSK_TCHAR * path, CaseDbConnectionInfo * info) +{ #if defined(HAVE_POSTGRESQL) && defined(TSK_WIN32) - // ELTODO: check here which database to initialize - //TskDb *db = new TskDbSqlite(path, true); TskDb *db = new TskDbPostgreSQL(path, true); -#else - TskDb *db = new TskDbSqlite(path, true); -#endif // HAVE_POSTGRESQL && TSK_WIN32 + + // Store connection info for the multi-user database + if (db->setConnectionInfo(info) != TSK_OK) { + delete(db); + return NULL; + } // Confirm that database already exsists if (!db->dbExists()) { @@ -107,6 +171,7 @@ TskCaseDb::openDb(const TSK_TCHAR * path) tsk_error_set_errno(TSK_ERR_AUTO_DB); tsk_error_set_errstr("Database %" PRIttocTSK " does not exist. Must be created first.", path); + delete(db); return NULL; } @@ -117,6 +182,9 @@ TskCaseDb::openDb(const TSK_TCHAR * path) } return new TskCaseDb(db); +#else + return NULL; +#endif // HAVE_POSTGRESQL && TSK_WIN32 } /** diff --git a/tsk/auto/db_connection_info.h b/tsk/auto/db_connection_info.h new file mode 100644 index 0000000000000000000000000000000000000000..4d30b9f2e7c5dee026470d487416db624969b919 --- /dev/null +++ b/tsk/auto/db_connection_info.h @@ -0,0 +1,72 @@ +/* +** The Sleuth Kit +** +** Brian Carrier [carrier <at> sleuthkit [dot] org] +** Copyright (c) 2010-2013 Brian Carrier. All Rights reserved +** +** This software is distributed under the Common Public License 1.0 +** +*/ + +/** +* \file db_connection_info.h +* Contains multi-user database connection information. +*/ + +#ifndef _DB_CONNECTION_INFO_H +#define _DB_CONNECTION_INFO_H + +#include <string> +using std::string; + +class CaseDbConnectionInfo +{ +public: + + enum DbType + { + // Add any additional remote database types here. + // Be sure to add to settingsValid() if you add a type here. + UNKNOWN, + POSTGRESQL + }; + +private: + string hostNameOrIP; + string portNumber; + string userName; + string password; + DbType dbType; + +public: + + CaseDbConnectionInfo(string lhostNameOrIP, string lportNumber, string luserName, string lpassword, DbType ldbType) { + this->hostNameOrIP = lhostNameOrIP; + this->portNumber = lportNumber; + this->userName = luserName; + this->password = lpassword; + this->dbType = ldbType; + } + + DbType getDbType() { + return this->dbType; + } + + string getHost() { + return this->hostNameOrIP; + } + + string getPort() { + return this->portNumber; + } + + string getUserName() { + return this->userName; + } + + string getPassword() { + return this->password; + } +}; + +#endif //_DB_CONNECTION_INFO_H \ No newline at end of file diff --git a/tsk/auto/db_postgresql.cpp b/tsk/auto/db_postgresql.cpp index 317d7bd99d365961b37eea12a18a97dca9712e00..a9b0fd1c003ee5a31728c0a8831b0145d21c17d2 100755 --- a/tsk/auto/db_postgresql.cpp +++ b/tsk/auto/db_postgresql.cpp @@ -33,9 +33,8 @@ TskDbPostgreSQL::TskDbPostgreSQL(const TSK_TCHAR * a_dbFilePath, bool a_blkMapFl : TskDb(a_dbFilePath, a_blkMapFlag) { conn = NULL; - wcsncpy(m_dBName, a_dbFilePath, 255); + wcsncpy(m_dBName, a_dbFilePath, MAX_CONN_INFO_FIELD_LENGTH - 1); m_blkMapFlag = a_blkMapFlag; - setLogInInfo(); } TskDbPostgreSQL::~TskDbPostgreSQL() @@ -46,38 +45,78 @@ TskDbPostgreSQL::~TskDbPostgreSQL() } } -TSK_RETVAL_ENUM TskDbPostgreSQL::setLogInInfo(){ +TSK_RETVAL_ENUM TskDbPostgreSQL::setConnectionInfo(CaseDbConnectionInfo * info){ - strncpy(userName, "postgres", sizeof(userName)); - strncpy(password, "simple41", sizeof(password)); - strncpy(hostIpAddr, "127.0.0.1", sizeof(hostIpAddr)); - strncpy(hostPort, "5432", sizeof(hostPort)); + if (info->getDbType() != CaseDbConnectionInfo::POSTGRESQL) { + tsk_error_reset(); + tsk_error_set_errno(TSK_ERR_AUTO_DB); + tsk_error_set_errstr("TskDbPostgreSQL::setConnectionInfo: Connection info is for wrong database type %d", info->getDbType()); + return TSK_ERR; + } + + // verify input string sizes + if (verifyConnectionInfoStringLengths(info->getUserName().size(), info->getPassword().size(), info->getHost().size(), info->getPort().size()) != TSK_OK) { + return TSK_ERR; + } + + strncpy(userName, info->getUserName().c_str(), sizeof(userName)); + strncpy(password, info->getPassword().c_str(), sizeof(password)); + strncpy(hostIpAddr, info->getHost().c_str(), sizeof(hostIpAddr)); + strncpy(hostPort, info->getPort().c_str(), sizeof(hostPort)); + +// strncpy(userName, "postgres", sizeof(userName)); +// strncpy(password, "simple41", sizeof(password)); +// strncpy(hostIpAddr, "127.0.0.1", sizeof(hostIpAddr)); +// strncpy(hostPort, "5432", sizeof(hostPort)); return TSK_OK; } -PGconn* TskDbPostgreSQL::connectToDatabase(TSK_TCHAR *dbName) { +TSK_RETVAL_ENUM TskDbPostgreSQL::verifyConnectionInfoStringLengths(size_t userNameStrLen, size_t pwdStrLen, size_t hostNameStrLen, size_t portStrLen) { - // Make a connection to postgres database server - char connectionString[1024]; + if (userNameStrLen >= MAX_CONN_INFO_FIELD_LENGTH - 1) { + tsk_error_reset(); + tsk_error_set_errno(TSK_ERR_AUTO_DB); + tsk_error_set_errstr("TskDbPostgreSQL::connectToDatabase: User name is too long. Length = %d, Max length = %d", userNameStrLen, MAX_CONN_INFO_FIELD_LENGTH - 1); + return TSK_ERR; + } - // verify user name and password string sizes - if (strlen(userName) >= MAX_USER_NAME_PASSWORD_LENGTH) { + if (pwdStrLen >= MAX_CONN_INFO_FIELD_LENGTH - 1) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_DB); - tsk_error_set_errstr("User name is too long. Length = %d, Max length = %d", strlen(userName), MAX_USER_NAME_PASSWORD_LENGTH); - return NULL; + tsk_error_set_errstr("TskDbPostgreSQL::connectToDatabase: Password is too long. Length = %d, Max length = %d", pwdStrLen, MAX_CONN_INFO_FIELD_LENGTH - 1); + return TSK_ERR; } - if (strlen(password) >= MAX_USER_NAME_PASSWORD_LENGTH) { + if (hostNameStrLen >= MAX_CONN_INFO_FIELD_LENGTH - 1) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_DB); - tsk_error_set_errstr("Password is too long. Length = %d, Max length = %d", strlen(password), MAX_USER_NAME_PASSWORD_LENGTH); + tsk_error_set_errstr("TskDbPostgreSQL::connectToDatabase: Host name is too long. Length = %d, Max length = %d", hostNameStrLen, MAX_CONN_INFO_FIELD_LENGTH - 1); + return TSK_ERR; + } + + if (portStrLen > MAX_CONN_PORT_FIELD_LENGTH) { + tsk_error_reset(); + tsk_error_set_errno(TSK_ERR_AUTO_DB); + tsk_error_set_errstr("TskDbPostgreSQL::connectToDatabase: Host port string is too long. Length = %d, Max length = %d", portStrLen, MAX_CONN_PORT_FIELD_LENGTH); + return TSK_ERR; + } + + return TSK_OK; +} + +PGconn* TskDbPostgreSQL::connectToDatabase(TSK_TCHAR *dbName) { + + // Make a connection to postgres database server + char connectionString[1024]; + + // verify input string sizes + if (verifyConnectionInfoStringLengths(strlen(userName), strlen(password), strlen(hostIpAddr), strlen(hostPort)) != TSK_OK) { return NULL; } // escape strings for use within an SQL command. Usually use PQescapeLiteral but it requires connection to be already established. - char userName_sql[256]; - char password_sql[256]; + char userName_sql[MAX_CONN_INFO_FIELD_LENGTH]; + char password_sql[MAX_CONN_INFO_FIELD_LENGTH]; PQescapeString(&userName_sql[0], userName, strlen(userName)); PQescapeString(&password_sql[0], password, strlen(password)); @@ -85,7 +124,7 @@ PGconn* TskDbPostgreSQL::connectToDatabase(TSK_TCHAR *dbName) { PGconn *dbConn = PQconnectdb(connectionString); // Check to see that the backend connection was successfully made - if (verifyResultCode(PQstatus(dbConn), CONNECTION_OK, "Connection to PostgreSQL database failed, result code %d")) + if (verifyResultCode(PQstatus(dbConn), CONNECTION_OK, "TskDbPostgreSQL::connectToDatabase: Connection to PostgreSQL database failed, result code %d")) { PQfinish(dbConn); return NULL; @@ -126,7 +165,7 @@ TSK_RETVAL_ENUM TskDbPostgreSQL::createDatabase(){ tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_DB); char * str = PQerrorMessage(serverConn); - tsk_error_set_errstr("Database creation failed, %s", str); + tsk_error_set_errstr("TskDbPostgreSQL::createDatabase: Database creation failed, %s", str); result = TSK_ERR; } @@ -148,7 +187,7 @@ int TskDbPostgreSQL::open(bool createDbFlag) if (createDbFlag) { // create new database first - if (verifyResultCode(createDatabase(), TSK_OK, "TskDbPostgreSQL::open - Unable to create database, result code %d")){ + if (verifyResultCode(createDatabase(), TSK_OK, "TskDbPostgreSQL::open: Unable to create database, result code %d")){ return -1; } } @@ -158,7 +197,7 @@ int TskDbPostgreSQL::open(bool createDbFlag) if (!conn){ tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_DB); - tsk_error_set_errstr("TskDbPostgreSQL::open - Couldn't connect to databse %S", m_dBName); + tsk_error_set_errstr("TskDbPostgreSQL::open: Couldn't connect to databse %S", m_dBName); return -1; } @@ -167,7 +206,7 @@ int TskDbPostgreSQL::open(bool createDbFlag) if (initialize()) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_DB); - tsk_error_set_errstr("TskDbPostgreSQL::open - Couldn't initialize databse %S", m_dBName); + tsk_error_set_errstr("TskDbPostgreSQL::open: Couldn't initialize databse %S", m_dBName); close(); // close connection to database return -1; } @@ -210,7 +249,7 @@ bool TskDbPostgreSQL::dbExists() { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_DB); char * str = PQerrorMessage(conn); - tsk_error_set_errstr("Existing database lookup failed, %s", str); + tsk_error_set_errstr("TskDbPostgreSQL::dbExists: Existing database lookup failed, %s", str); numDb = 0; } else { // number of existing databases that matched name (if search is case sensitive then max is 1) diff --git a/tsk/auto/tsk_case_db.h b/tsk/auto/tsk_case_db.h index 9315ad422c1857a135a1dcb27f8c653e16411a25..ba502cdd44e360694df58f41c432d69a8787b051 100644 --- a/tsk/auto/tsk_case_db.h +++ b/tsk/auto/tsk_case_db.h @@ -172,7 +172,9 @@ class TskCaseDb { ~TskCaseDb(); static TskCaseDb *newDb(const TSK_TCHAR * path); + static TskCaseDb *newDb(const TSK_TCHAR * const path, CaseDbConnectionInfo * info); static TskCaseDb *openDb(const TSK_TCHAR * path); + static TskCaseDb *openDb(const TSK_TCHAR * path, CaseDbConnectionInfo * info); void clearLookupDatabases(); uint8_t setNSRLHashDb(TSK_TCHAR * const indexFile); diff --git a/tsk/auto/tsk_db.cpp b/tsk/auto/tsk_db.cpp index de6279fd8b92cfccb22c2e7ae1339e08af9087dd..8be4bc191a8915709b6e70a5761b9f762ad2f4d6 100755 --- a/tsk/auto/tsk_db.cpp +++ b/tsk/auto/tsk_db.cpp @@ -32,3 +32,11 @@ TskDb::TskDb(const TSK_TCHAR * a_dbFilePath, bool a_blkMapFlag) } #endif +/** +* Store database connection info. NO-OP for single-user database. Multi-user database class +* needs to derive and implement this method. +*/ +TSK_RETVAL_ENUM TskDb::setConnectionInfo(CaseDbConnectionInfo * info){ + return TSK_OK; +} + diff --git a/tsk/auto/tsk_db.h b/tsk/auto/tsk_db.h index 54923e87564027b13e06fcb445b7d61b21d0861d..d2b5c088dbbb0fd6e108a04662c8e420d4097129 100755 --- a/tsk/auto/tsk_db.h +++ b/tsk/auto/tsk_db.h @@ -22,6 +22,7 @@ #include <ostream> #include "tsk_auto_i.h" +#include "db_connection_info.h" using std::ostream; using std::vector; @@ -158,6 +159,7 @@ class TskDb { virtual ~TskDb() {}; virtual int open(bool) = 0; virtual int close() = 0; + virtual TSK_RETVAL_ENUM setConnectionInfo(CaseDbConnectionInfo * info); virtual int addImageInfo(int type, int size, int64_t & objId, const string & timezone) = 0; virtual int addImageInfo(int type, int size, int64_t & objId, const string & timezone, TSK_OFF_T, const string &md5) = 0; virtual int addImageName(int64_t objId, char const *imgName, int sequence) = 0; diff --git a/tsk/auto/tsk_db_postgresql.h b/tsk/auto/tsk_db_postgresql.h index 1ff226cf8f5d702acc2c12e8ffdb24886bc23072..bf1547bd426c428a0aaf068a8cdf3bd3ae129b39 100755 --- a/tsk/auto/tsk_db_postgresql.h +++ b/tsk/auto/tsk_db_postgresql.h @@ -30,8 +30,8 @@ #include <map> using std::map; -#define MAX_USER_NAME_PASSWORD_LENGTH 255 - +#define MAX_CONN_INFO_FIELD_LENGTH 256 +#define MAX_CONN_PORT_FIELD_LENGTH 5 // port is a 5 digit number /** \internal * C++ class that wraps PostgreSQL database internals. @@ -43,7 +43,7 @@ class TskDbPostgreSQL : public TskDb { int open(bool); int close(); - TSK_RETVAL_ENUM setLogInInfo(); + TSK_RETVAL_ENUM setConnectionInfo(CaseDbConnectionInfo * info); int addImageInfo(int type, int size, int64_t & objId, const string & timezone); int addImageInfo(int type, int size, int64_t & objId, const string & timezone, TSK_OFF_T, const string &md5); @@ -92,11 +92,12 @@ class TskDbPostgreSQL : public TskDb { PGconn *conn; bool m_blkMapFlag; - TSK_TCHAR m_dBName[256]; - char userName[128]; - char password[128]; - char hostIpAddr[64]; + TSK_TCHAR m_dBName[MAX_CONN_INFO_FIELD_LENGTH]; + char userName[MAX_CONN_INFO_FIELD_LENGTH]; + char password[MAX_CONN_INFO_FIELD_LENGTH]; + char hostIpAddr[MAX_CONN_INFO_FIELD_LENGTH]; char hostPort[16]; + TSK_RETVAL_ENUM verifyConnectionInfoStringLengths(size_t userNameStrLen, size_t pwdStrLen, size_t hostNameStrLen, size_t portStrLen); PGconn* connectToDatabase(TSK_TCHAR *dbName); TSK_RETVAL_ENUM createDatabase(); diff --git a/win32/libtsk/libtsk.vcxproj b/win32/libtsk/libtsk.vcxproj index 7da655c71abdad41664ab5d21abefbc7905c6b3d..e32c0b0ea0b874baa76b463b5af23165d56708e6 100755 --- a/win32/libtsk/libtsk.vcxproj +++ b/win32/libtsk/libtsk.vcxproj @@ -461,6 +461,7 @@ copy "$(POSTGRESQL_HOME_64)\bin\libintl-8.dll" "$(OutDir)"</Command> <ClCompile Include="..\..\tsk\img\raw.c" /> </ItemGroup> <ItemGroup> + <ClInclude Include="..\..\tsk\auto\db_connection_info.h" /> <ClInclude Include="..\..\tsk\auto\tsk_db.h" /> <ClInclude Include="..\..\tsk\auto\tsk_db_postgresql.h" /> <ClInclude Include="..\..\tsk\fs\tsk_exfatfs.h" /> diff --git a/win32/libtsk/libtsk.vcxproj.filters b/win32/libtsk/libtsk.vcxproj.filters index 5cb27b5d31e6fc336e095657e6ef8c0d0090270d..db1c0e2bff081cda1c664f8f4e8abcb4705b9af2 100755 --- a/win32/libtsk/libtsk.vcxproj.filters +++ b/win32/libtsk/libtsk.vcxproj.filters @@ -419,5 +419,8 @@ <ClInclude Include="..\..\tsk\auto\tsk_db_postgresql.h"> <Filter>auto</Filter> </ClInclude> + <ClInclude Include="..\..\tsk\auto\db_connection_info.h"> + <Filter>auto</Filter> + </ClInclude> </ItemGroup> </Project> \ No newline at end of file