Merge pull request #308 Fix build warning due to string truncation from stauffer-garmin/master

This commit is contained in:
Sébastien Rombauts 2020-11-18 08:36:34 +01:00 committed by GitHub
commit 721b245045
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -310,7 +310,8 @@ Header Database::getHeaderInfo(const std::string& aFilename)
} }
// If the "magic string" can't be found then header is invalid, corrupt or unreadable // If the "magic string" can't be found then header is invalid, corrupt or unreadable
strncpy(pHeaderStr, pBuf, 16); memcpy(pHeaderStr, pBuf, 16);
pHeaderStr[15] = '\0';
if (strncmp(pHeaderStr, "SQLite format 3", 15) != 0) if (strncmp(pHeaderStr, "SQLite format 3", 15) != 0)
{ {
throw SQLite::Exception("Invalid or encrypted SQLite header in file " + aFilename); throw SQLite::Exception("Invalid or encrypted SQLite header in file " + aFilename);