Project

General

Profile

Bug #11262 ยป 0001-WT-11262-replace-uses-of-stat-with-boost-filesystem.patch

Patch - Roel Standaert, 01/20/2023 02:48 PM

View differences:

ReleaseNotes.html
</li>
</ul>
<h2>Release 4.9.2 (TBD)</h2>
<p>
Wt 4.9.2 is a patch release that addresses the following issues:
</p>
<ul>
<li>
<a href="https://redmine.emweb.be/issues/11262" target="_blank">Issue #11262</a>:
fixed an issue where 32 bit Linux builds could cause <code>stat()</code> to
fail with <code>EOVERFLOW</code>.
</li>
</ul>
<h2>Release 4.9.1 (January 20, 2023)</h2>
<p>
examples/CMakeLists.txt
IF(${Boost_FOUND})
SET(BOOST_FS_LIB ${Boost_FILESYSTEM_LIBRARY})
set(BOOST_SYSTEM_LIB "")
SET(BOOST_WT_FOUND true)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
examples/gitmodel/Git.C
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/split.hpp>
#include <sys/stat.h>
#include <boost/filesystem.hpp>
using namespace Wt;
......
void Git::setRepositoryPath(const std::string& repositoryPath)
{
struct stat sb;
is_bare_ = !(stat((repositoryPath + "/.git").c_str(), &sb) == 0 &&
S_ISDIR(sb.st_mode));
namespace fs = boost::filesystem;
boost::system::error_code ignored;
is_bare_ = !fs::is_directory(fs::path(repositoryPath) / ".git", ignored);
repository_ = repositoryPath;
checkRepository();
}
examples/widgetgallery/CMakeLists.txt
${WIDGETGALLERY_SOURCES}
)
if(NOT WIN32)
target_link_libraries(widgetgallery.wt ${BOOST_FS_LIB} ${BOOST_SYSTEM_LIB})
endif()
IF(TARGET Boost::headers)
TARGET_LINK_LIBRARIES(widgetgallery.wt Boost::headers)
ENDIF()
src/fcgi/CMakeLists.txt
TARGET_LINK_LIBRARIES(wtfcgi PRIVATE ${WT_THREAD_LIB})
ENDIF(MULTI_THREADED_BUILD)
target_link_libraries(wtfcgi PRIVATE ${BOOST_FS_LIB} ${BOOST_SYSTEM_LIB})
SET_TARGET_PROPERTIES(
wtfcgi
PROPERTIES
src/fcgi/Server.C
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
......
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
using std::exit;
using std::strcpy;
using std::strlen;
......
* See if the session is alive.
*/
if (haveSessionId) {
struct stat finfo;
// exists, try to connect (for 1 second)
std::string path = socketPath(sessionId);
if (stat(path.c_str(), &finfo) != -1)
boost::system::error_code ignored;
if (boost::filesystem::exists(path, ignored)) {
clientSocket = connectToSession(sessionId, path, 10);
}
}
while (clientSocket == -1) {
src/http/Configuration.C
#include "WebUtils.h"
#include "StringUtils.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <boost/filesystem.hpp>
#ifndef WT_WIN32
#include <unistd.h>
#endif
......
return e;
}
#ifdef _MSC_VER
static inline bool S_ISREG(unsigned short mode)
{
return (mode & S_IFREG) != 0;
}
static inline bool S_ISDIR(unsigned short mode)
{
return (mode & S_IFDIR) != 0;
}
#endif
void Configuration::checkPath(const po::variables_map& vm,
std::string varName,
std::string varDescription,
......
std::string varDescription,
int options)
{
struct stat t;
if (stat(result.c_str(), &t) != 0) {
std::perror("stat");
namespace fs = boost::filesystem;
boost::system::error_code ec;
const auto status = fs::status(result, ec);
if (ec) {
throw Wt::WServer::Exception(varDescription
+ " (\"" + result + "\") not valid: "
+ ec.message());
} else if (!exists(status)) {
throw Wt::WServer::Exception(varDescription
+ " (\"" + result + "\") not valid.");
+ " (\"" + result + "\") does not exist.");
} else {
if (options & Directory) {
while (result[result.length()-1] == '/')
result = result.substr(0, result.length() - 1);
if (!S_ISDIR(t.st_mode)) {
if (!is_directory(status)) {
throw Wt::WServer::Exception(varDescription + " (\"" + result
+ "\") must be a directory.");
}
}
if (options & RegularFile) {
if (!S_ISREG(t.st_mode)) {
if (!is_regular_file(status)) {
throw Wt::WServer::Exception(varDescription + " (\"" + result
+ "\") must be a regular file.");
}
}
#ifndef WT_WIN32
if (options & Private) {
if (t.st_mode & (S_IRWXG | S_IRWXO)) {
if ((status.permissions() & (fs::perms::group_all | fs::perms::others_all)) != fs::perms::no_perms) {
throw Wt::WServer::Exception(varDescription + " (\"" + result
+ "\") must be unreadable for group and others.");
}
src/web/Configuration.C
#include "WebUtils.h"
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#ifdef WT_BOOST_CONF_LOCK
#include <boost/thread.hpp>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <algorithm>
#include <array>
......
if (!newId.empty()) {
std::string socketPath = sessionSocketPath(newId);
struct stat finfo;
if (stat(socketPath.c_str(), &finfo) != -1)
namespace fs = boost::filesystem;
boost::system::error_code ignored;
if (fs::exists(socketPath, ignored)) {
return false;
}
if (oldId.empty()) {
if (sessionPolicy_ == SharedProcess) {
    (1-1/1)