summaryrefslogtreecommitdiffstats
path: root/wsd/FileServer.cpp
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-05-23 16:33:41 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-05-23 16:42:59 +0200
commitd79666092d7d38eeea4fd18cea1c060e1fce7cdc (patch)
tree7b32b08faddeb3b6def74a9d7ff4c95dcc1ce5f2 /wsd/FileServer.cpp
parentAllow 'make run' after 'make build-nocheck' (diff)
downloadonline-d79666092d7d38eeea4fd18cea1c060e1fce7cdc.tar.gz
online-d79666092d7d38eeea4fd18cea1c060e1fce7cdc.zip
wsd: avoid UB in FileServerRequestHandler::readDirToHash()
wsd/FileServer.cpp:464:35: runtime error: null pointer passed as argument 1, which is declared to never be null /usr/include/dirent.h:162:45: note: nonnull attribute specified here #0 0xbf566b in FileServerRequestHandler::readDirToHash(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/vmiklos/lode/dev/online/wsd/FileServer.cpp:464:27 #1 0xbf8417 in FileServerRequestHandler::initialize() /home/vmiklos/lode/dev/online/wsd/FileServer.cpp:531:13 #2 0x98617a in LOOLWSD::initialize(Poco::Util::Application&) /home/vmiklos/lode/dev/online/wsd/LOOLWSD.cpp:1155:5 #3 0x7f17fc9c8263 in Poco::Util::Application::run() (/usr/lib64/libPocoUtil.so.60+0x3e263) #4 0x9c29f3 in main /home/vmiklos/lode/dev/online/wsd/LOOLWSD.cpp:3466:1 #5 0x7f17fa739f49 in __libc_start_main (/lib64/libc.so.6+0x20f49) #6 0x5c1e19 in _start /home/abuild/rpmbuild/BUILD/glibc-2.26/csu/../sysdeps/x86_64/start.S:120 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior wsd/FileServer.cpp:464:35 in Change-Id: Iadb90c4e98981283718be3e3e9f55cb0b7a3e917
Diffstat (limited to 'wsd/FileServer.cpp')
-rw-r--r--wsd/FileServer.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index 707e0b33df..cbdcea1728 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -461,6 +461,9 @@ void FileServerRequestHandler::readDirToHash(const std::string &basePath, const
LOG_TRC("Pre-reading directory: " << basePath << path);
workingdir = opendir((basePath + path).c_str());
+ if (!workingdir)
+ return;
+
while ((currentFile = readdir(workingdir)) != nullptr)
{
if (currentFile->d_name[0] == '.')