Fix bug where a comma in the base directory name would make the file system fail to mount, https://github.com/cryfs/cryfs/issues/326
This commit is contained in:
parent
35b44d6e21
commit
9cbc12fc57
@ -517,7 +517,7 @@ jobs:
|
|||||||
OMP_NUM_THREADS: "1"
|
OMP_NUM_THREADS: "1"
|
||||||
CXXFLAGS: "-O2 -fsanitize=thread -fno-omit-frame-pointer"
|
CXXFLAGS: "-O2 -fsanitize=thread -fno-omit-frame-pointer"
|
||||||
BUILD_TYPE: "Debug"
|
BUILD_TYPE: "Debug"
|
||||||
GTEST_ARGS: "--gtest_filter=-LoggingTest.LoggingAlsoWorksAfterFork:AssertTest_*:BacktraceTest.*:SignalCatcherTest.*_thenDies:SignalHandlerTest.*_thenDies:SignalHandlerTest.givenMultipleSigIntHandlers_whenRaising_thenCatchesCorrectSignal:CliTest_Setup.*:CliTest_IntegrityCheck.*:*/CliTest_WrongEnvironment.*:CliTest_Unmount.*"
|
GTEST_ARGS: "--gtest_filter=-LoggingTest.LoggingAlsoWorksAfterFork:AssertTest_*:BacktraceTest.*:SignalCatcherTest.*_thenDies:SignalHandlerTest.*_thenDies:SignalHandlerTest.givenMultipleSigIntHandlers_whenRaising_thenCatchesCorrectSignal:CliTest_Setup.*:CliTest_IntegrityCheck.*:*/CliTest_WrongEnvironment.*:CliTest_Unmount.*:CliTest.WorksWithCommasInBasedir"
|
||||||
CMAKE_FLAGS: ""
|
CMAKE_FLAGS: ""
|
||||||
RUN_TESTS: true
|
RUN_TESTS: true
|
||||||
clang_tidy:
|
clang_tidy:
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Version 0.10.3 (unreleased)
|
||||||
|
---------------
|
||||||
|
Fixed bugs:
|
||||||
|
* A comma in the base directory name would make the file system fail to mount, https://github.com/cryfs/cryfs/issues/326
|
||||||
|
|
||||||
Version 0.10.2
|
Version 0.10.2
|
||||||
---------------
|
---------------
|
||||||
Fixed bugs:
|
Fixed bugs:
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <csignal>
|
#include <csignal>
|
||||||
#include "InvalidFilesystem.h"
|
#include "InvalidFilesystem.h"
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
@ -290,7 +291,9 @@ vector<char *> Fuse::_build_argv(const bf::path &mountdir, const vector<string>
|
|||||||
argv.push_back(_create_c_string(option));
|
argv.push_back(_create_c_string(option));
|
||||||
}
|
}
|
||||||
_add_fuse_option_if_not_exists(&argv, "subtype", _fstype);
|
_add_fuse_option_if_not_exists(&argv, "subtype", _fstype);
|
||||||
_add_fuse_option_if_not_exists(&argv, "fsname", _fsname.get_value_or(_fstype));
|
auto fsname = _fsname.get_value_or(_fstype);
|
||||||
|
boost::replace_all(fsname, ",", "\\,"); // Avoid fuse options parser bug where a comma in the fsname is misinterpreted as an options delimiter, see https://github.com/cryfs/cryfs/issues/326
|
||||||
|
_add_fuse_option_if_not_exists(&argv, "fsname", fsname);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// Make volume name default to mountdir on macOS
|
// Make volume name default to mountdir on macOS
|
||||||
_add_fuse_option_if_not_exists(&argv, "volname", mountdir.filename().string());
|
_add_fuse_option_if_not_exists(&argv, "volname", mountdir.filename().string());
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
using cpputils::TempFile;
|
using cpputils::TempFile;
|
||||||
|
|
||||||
|
namespace bf = boost::filesystem;
|
||||||
|
|
||||||
//Tests that cryfs is correctly setup according to the CLI parameters specified
|
//Tests that cryfs is correctly setup according to the CLI parameters specified
|
||||||
using CliTest_Setup = CliTest;
|
using CliTest_Setup = CliTest;
|
||||||
|
|
||||||
@ -36,4 +38,12 @@ TEST_F(CliTest_Setup, FuseOptionGiven) {
|
|||||||
//Specify --cipher parameter to make it non-interactive
|
//Specify --cipher parameter to make it non-interactive
|
||||||
//TODO Remove "-f" parameter, once EXPECT_RUN_SUCCESS can handle that
|
//TODO Remove "-f" parameter, once EXPECT_RUN_SUCCESS can handle that
|
||||||
EXPECT_RUN_SUCCESS({basedir.string().c_str(), mountdir.string().c_str(), "-f", "--cipher", "aes-256-gcm", "--", "-f"}, mountdir);
|
EXPECT_RUN_SUCCESS({basedir.string().c_str(), mountdir.string().c_str(), "-f", "--cipher", "aes-256-gcm", "--", "-f"}, mountdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(CliTest, WorksWithCommasInBasedir) {
|
||||||
|
// This test makes sure we don't regress on https://github.com/cryfs/cryfs/issues/326
|
||||||
|
//TODO Remove "-f" parameter, once EXPECT_RUN_SUCCESS can handle that
|
||||||
|
auto basedir_ = basedir / "pathname,with,commas";
|
||||||
|
bf::create_directory(basedir_);
|
||||||
|
EXPECT_RUN_SUCCESS({basedir_.string().c_str(), mountdir.string().c_str(), "-f"}, mountdir);
|
||||||
|
}
|
||||||
|
@ -75,12 +75,21 @@ public:
|
|||||||
//TODO Make this work when run in background
|
//TODO Make this work when run in background
|
||||||
ASSERT(std::find(args.begin(), args.end(), string("-f")) != args.end(), "Currently only works if run in foreground");
|
ASSERT(std::find(args.begin(), args.end(), string("-f")) != args.end(), "Currently only works if run in foreground");
|
||||||
|
|
||||||
FilesystemOutput filesystem_output = run_filesystem(args, mountDir, std::move(onMounted));
|
bool successfully_mounted = false;
|
||||||
|
|
||||||
|
FilesystemOutput filesystem_output = run_filesystem(args, mountDir, [&] {
|
||||||
|
successfully_mounted = true;
|
||||||
|
onMounted();
|
||||||
|
});
|
||||||
|
|
||||||
EXPECT_EQ(0, filesystem_output.exit_code);
|
EXPECT_EQ(0, filesystem_output.exit_code);
|
||||||
if (!std::regex_search(filesystem_output.stdout_, std::regex("Mounting filesystem"))) {
|
if (!std::regex_search(filesystem_output.stdout_, std::regex("Mounting filesystem"))) {
|
||||||
std::cerr << filesystem_output.stdout_ << std::endl;
|
std::cerr << "STDOUT:\n" << filesystem_output.stdout_ << "STDERR:\n" << filesystem_output.stderr_ << std::endl;
|
||||||
EXPECT_TRUE(false);
|
EXPECT_TRUE(false) << "Filesystem did not output the 'Mounting filesystem' message, probably wasn't successfully mounted.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!successfully_mounted) {
|
||||||
|
EXPECT_TRUE(false) << "Filesystem did not call onMounted callback, probably wasn't successfully mounted.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user