Skip to content

Commit 6e1bd7b

Browse files
authored
Merge pull request #377 from runloopai/adam/fix-buffer-overflow-sha256
Fix buffer-overflow in sha256 string construction
2 parents 4601fb2 + b94d3e5 commit 6e1bd7b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/tools/sha256file.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ string sha256sum(const char *fn) {
103103
}
104104
}
105105
SHA256_Final(sha, &ctx);
106-
char res[SHA256_DIGEST_LENGTH * 2];
106+
char res[SHA256_DIGEST_LENGTH * 2 + 1];
107107
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)
108108
sprintf(res + (i * 2), "%02x", sha[i]);
109109
return "sha256:" + std::string(res, SHA256_DIGEST_LENGTH * 2);

0 commit comments

Comments
 (0)