Skip to content

Commit

Permalink
fix(ArchiveAscii): broken raw output generation
Browse files Browse the repository at this point in the history
Fixes a buffer overflow issue due to an unterminated c-string being passed to a function expecting one. Solution: add a null-terminator of course.
  • Loading branch information
lmichaelis committed Feb 15, 2025
1 parent 3b71ad5 commit f24c8a0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/archive/ArchiveAscii.cc
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ namespace zenkit {
this->_m_write->write_string(name);
this->_m_write->write_string("=raw:");

std::array<char, 2> buf {};
std::array<char, 3> buf {};
buf[2] = '\0';
for (auto i = 0u; i < length; ++i) {
std::to_chars(buf.data(), buf.data() + buf.size(), static_cast<unsigned char>(v[i]), 16);

Expand Down

0 comments on commit f24c8a0

Please sign in to comment.