Skip to content

Commit 56a461f

Browse files
committed
wallet: fix buffer over-read in SQLite file magic check
If there is no terminating zero within the 16 magic bytes, the buffer would be over-read in the std::string constructor. Fixed by using the "from buffer" variant of the ctor (that also takes a size) rather than the "from c-string" variant.
1 parent dda18e7 commit 56a461f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/wallet/sqlite.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,8 @@ bool IsSQLiteFile(const fs::path& path)
619619
file.close();
620620

621621
// Check the magic, see https://sqlite.org/fileformat2.html
622-
std::string magic_str(magic);
623-
if (magic_str != std::string("SQLite format 3")) {
622+
std::string magic_str(magic, 16);
623+
if (magic_str != std::string("SQLite format 3", 16)) {
624624
return false;
625625
}
626626

0 commit comments

Comments
 (0)