mirror of
https://github.com/LibreOffice/online.git
synced 2025-08-03 16:05:07 +00:00
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
This commit is contained in:
@ -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] == '.')
|
||||
|
Reference in New Issue
Block a user