[Libreoffice-commits] online.git: test/WopiTestServer.hpp
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Wed Aug 7 07:11:41 UTC 2019
test/WopiTestServer.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 59c9f70c1f4cdfd7b4c9113a05d78ade8e513d70
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Aug 7 09:10:57 2019 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Aug 7 09:11:09 2019 +0200
test: avoid UB in unit-wopi
==16414==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address 0x7f81f8df5510 at pc 0x0000005eb5a4 bp 0x7f81f8df54b0 sp 0x7f81f8df4c60
READ of size 23 at 0x7f81f8df5510 thread T3 (websrv_poll)
#0 0x5eb5a3 in __interceptor_strlen.part.34 /home/vmiklos/git/libreoffice/lode/packages/llvm-472c6ef8b0f53061b049039f9775ab127beafbe4.src/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:365
#1 0x7f8201d22e47 in std::char_traits<char>::length(char const*) /home/vmiklos/git/libreoffice/lode/packages/gccbuild/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h:320
#2 0x7f8201d22e47 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) /home/vmiklos/git/libreoffice/lode/packages/gccbuild/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:511
#3 0x7f81fcaa59c3 in WopiTestServer::handleHttpRequest(Poco::Net::HTTPRequest const&, Poco::MemoryInputStream&, std::shared_ptr<StreamSocket>&) /home/vmiklos/git/libreoffice/online-san/test/./WopiTestServer.hpp:237:28
Problem was that the test code assumed a 0-terminated buffer, but that
was not the reality. So specify the buffer size explicitly.
Change-Id: I9a9edfe5623a1136aa77c381d1d3d8b8e1ca2258
diff --git a/test/WopiTestServer.hpp b/test/WopiTestServer.hpp
index d3533bc34..bdeecd96d 100644
--- a/test/WopiTestServer.hpp
+++ b/test/WopiTestServer.hpp
@@ -234,7 +234,7 @@ protected:
std::streamsize size = request.getContentLength();
char buffer[size];
message.read(buffer, size);
- setFileContent(buffer);
+ setFileContent(std::string(buffer, size));
assertPutFileRequest(request);
More information about the Libreoffice-commits
mailing list