Skip to content

Commit 529c817

Browse files
committed
Fixed MD5 stack overflow bug on macOS
Specifically, the std::string(const char* s, size_t n) constructor on macOS seems to ignore the n parameter and overflows. This was mitigated by adding a terminating character to s and using the std::string(const char* s) constructor instead.
1 parent 084c9cf commit 529c817

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • libtiledbvcf/external/md5

libtiledbvcf/external/md5/md5.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,10 @@ void md5_to_hex(const uint8_t* input, char* output) {
206206
}
207207

208208
std::string md5_to_hex(const uint8_t* input) {
209-
char output[32];
209+
char output[33];
210210
md5_to_hex(input, output);
211-
return std::string(output, 32);
211+
output[32] = '\0';
212+
return std::string(output);
212213
}
213214

214215
} // namespace md5

0 commit comments

Comments
 (0)