changeset 3299:fa8481daefd7

Fixed possible use of uninitialized value in Boost 1.69.0
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 22 Feb 2019 18:08:09 +0100
parents 8711cd9b47c5
children 5b7f56cf4a38
files Resources/Patches/boost-1.69.0-linux-standard-base.patch
diffstat 1 files changed, 37 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/Patches/boost-1.69.0-linux-standard-base.patch	Fri Feb 22 16:59:08 2019 +0100
+++ b/Resources/Patches/boost-1.69.0-linux-standard-base.patch	Fri Feb 22 18:08:09 2019 +0100
@@ -84,3 +84,40 @@
  } // namespace detail
  
  // this is the accessible definition of the trait to end user
+diff -urEb boost_1_69_0.orig/libs/filesystem/src/operations.cpp boost_1_69_0/libs/filesystem/src/operations.cpp
+--- boost_1_69_0.orig/libs/filesystem/src/operations.cpp	2019-02-22 15:05:32.566360008 +0100
++++ boost_1_69_0/libs/filesystem/src/operations.cpp	2019-02-22 18:04:17.346573047 +0100
+@@ -2111,9 +2111,16 @@
+     std::size_t path_size (0);  // initialization quiets gcc warning (ticket #3509)
+     error_code ec = path_max(path_size);
+     if (ec)return ec;
+-    dirent de;
+-    buffer = std::malloc((sizeof(dirent) - sizeof(de.d_name))
+-      +  path_size + 1); // + 1 for "/0"
++
++    // Fixed possible use of uninitialized dirent::d_type in dir_iterator
++    // https://github.com/boostorg/filesystem/commit/bbe9d1771e5d679b3f10c42a58fc81f7e8c024a9
++    const std::size_t buffer_size = (sizeof(dirent) - sizeof(dirent().d_name))
++      +  path_size + 1; // + 1 for "\0"
++    buffer = std::malloc(buffer_size);
++    if (BOOST_UNLIKELY(!buffer))
++      return make_error_code(boost::system::errc::not_enough_memory);
++    std::memset(buffer, 0, buffer_size);
++    
+     return ok;
+   }  
+ 
+@@ -2142,6 +2149,13 @@
+     *result = 0;
+     if ((p = ::readdir(dirp))== 0)
+       return errno;
++
++    // Fixed possible use of uninitialized dirent::d_type in dir_iterator
++    // https://github.com/boostorg/filesystem/commit/bbe9d1771e5d679b3f10c42a58fc81f7e8c024a9    
++#   ifdef BOOST_FILESYSTEM_STATUS_CACHE
++    entry->d_type = p->d_type;
++#   endif
++
+     std::strcpy(entry->d_name, p->d_name);
+     *result = entry;
+     return 0;