Opened 8 years ago

Last modified 5 years ago

#10450 new Bugs

Undefined behavior in boost::filesystem::detail::directory_iterator_construct

Reported by: egrindha@… Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.56.0 Severity: Problem
Keywords: Cc:

Description

boost/libs/filesystem/src/operations.cpp:2178:28: runtime error: reference binding to null pointer of type 'struct error_code'

The problem is this line: it.increment(*ec);

ec is 0 when directory_iterator_construct is called from operations.hpp:793

explicit directory_iterator(const path& p)
        : m_imp(new detail::dir_itr_imp)
          { detail::directory_iterator_construct(*this, p, 0); }
[...undefined behavior sanitiser noise...]
#3  0x00005555566e623c in boost::filesystem::detail::directory_iterator_construct (it=..., p=..., ec=ec@entry=0x0) at functional/boost/libs/filesystem/src/operations.cpp:2178
#4  0x00005555566b3cfe in directory_iterator (p=..., this=0x7fffffffd7e0) at functional/boost/boost/filesystem/operations.hpp:793
#5  recursive_directory_iterator (opt=boost::filesystem::none, dir_path=..., this=0x7fffffffd760) at functional/boost/boost/filesystem/operations.hpp:1037
[...my code...]

Attachments (1)

0001-Fix-null-pointer-dereference-in-boost.patch (1.1 KB ) - added by egrindha@… 8 years ago.
possible fix

Download all attachments as: .zip

Change History (4)

by egrindha@…, 8 years ago

possible fix

comment:1 by luc.hermitte@…, 6 years ago

I see the problem hasn't been fixed in boost 1.63.0 yet.

As a null value for ec in directory_iterator_increment() is legit, can't we simply change directory_iterator::increment(system::error_code&) into a function that expects a pointer?

comment:2 by anonymous, 5 years ago

Still not fixed in 1.65. Suggested patch: github.com/yandex/ClickHouse/commit/094c18bb46fc5d8ea7cbff80755187b7f4f7e81a

This is real bug (it cause segfault).

comment:3 by benoit.belley@…, 5 years ago

We are also hitting this issue. A fix would be nice.

Note: See TracTickets for help on using tickets.