diff --git a/include/LIEF/iostream.hpp b/include/LIEF/iostream.hpp index 247336742c..fbe4a3a77e 100644 --- a/include/LIEF/iostream.hpp +++ b/include/LIEF/iostream.hpp @@ -38,7 +38,14 @@ class vector_iostream { vector_iostream& put(uint8_t c); vector_iostream& write(const uint8_t* s, std::streamsize n); - vector_iostream& write(span sp); + vector_iostream& write(span sp) { + return write(sp.data(), sp.size()); + } + + vector_iostream& write(span sp) { + return write(sp.data(), sp.size()); + } + vector_iostream& write(std::vector s); vector_iostream& write(const std::string& s); vector_iostream& write(size_t count, uint8_t value); diff --git a/src/iostream.cpp b/src/iostream.cpp index a41c9fadf1..8f0e214182 100644 --- a/src/iostream.cpp +++ b/src/iostream.cpp @@ -86,10 +86,6 @@ vector_iostream& vector_iostream::write(std::vector s) { return *this; } -vector_iostream& vector_iostream::write(span s) { - return write(s.data(), s.size()); -} - vector_iostream& vector_iostream::write_sized_int(uint64_t value, size_t size) { const uint64_t stack_val = value; return write(reinterpret_cast(&stack_val), size); diff --git a/tests/pe/test_builder.py b/tests/pe/test_builder.py index 7d4f8683be..a28949bdb8 100644 --- a/tests/pe/test_builder.py +++ b/tests/pe/test_builder.py @@ -102,3 +102,16 @@ def test_imports_notepadpp(tmp_path): stdout, _ = kproc.communicate() print(stdout) assert kproc.returncode == 0 + + +def test_issue_952(tmp_path): + pe = lief.PE.parse(get_sample("PE/PE32_x86_binary_HelloWorld.exe")) + stub = bytes(pe.dos_stub) + assert not all(x == 0 for x in stub) + + out = tmp_path / "out.exe" + pe.write(out.as_posix()) + + new = lief.PE.parse(out.as_posix()) + print(bytes(new.dos_stub)) + assert bytes(new.dos_stub) == stub