Skip to content

Commit ce36da4

Browse files
committed
Bypass ASAN leak checks in help and version command paths for FUSE 2
Restrict the _exit(EXIT_SUCCESS) workaround to FUSE versions older than 3.0. This prevents LeakSanitizer from reporting a false positive 64-byte leak in libfuse2's fuse_chan_new while allowing modern FUSE 3 environments to use the standard C++ exit procedure. Verified that FUSE 3 does not exhibit the leak.
1 parent 7b4fdd9 commit ce36da4

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

mount-zip.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,20 +490,28 @@ static int ProcessArg(void* data,
490490
outargs->argv[0] = empty;
491491
fuse_main(outargs->argc, outargs->argv, &operations, nullptr);
492492
outargs->argv[0] = argv0;
493+
std::exit(EXIT_SUCCESS);
493494
#else
495+
dup2(STDOUT_FILENO, STDERR_FILENO);
494496
fuse_opt_add_arg(outargs, "-ho"); // I think ho means "help output".
495497
fuse_main(outargs->argc, outargs->argv, &operations, nullptr);
498+
_exit(EXIT_SUCCESS);
496499
#endif
497500
}
498-
std::exit(EXIT_SUCCESS);
499501

500502
case KEY_VERSION:
501503
std::cout << PROGRAM_NAME " version: " PROGRAM_VERSION "\n"
502504
<< "libzip version: " LIBZIP_VERSION "\n"
503505
<< std::flush;
504506
fuse_opt_add_arg(outargs, "--version");
507+
#if FUSE_USE_VERSION >= 30
505508
fuse_main(outargs->argc, outargs->argv, &operations, nullptr);
506509
std::exit(EXIT_SUCCESS);
510+
#else
511+
dup2(STDOUT_FILENO, STDERR_FILENO);
512+
fuse_main(outargs->argc, outargs->argv, &operations, nullptr);
513+
_exit(EXIT_SUCCESS);
514+
#endif
507515

508516
case FUSE_OPT_KEY_NONOPT:
509517
if (param.paths.emplace_back(arg).empty()) {

tests/node_test.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
// You should have received a copy of the GNU General Public License
1414
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1515

16+
#include "node.h"
17+
1618
#include <gtest/gtest.h>
1719
#include <sys/stat.h>
1820
#include <iostream>
1921
#include <sstream>
20-
#include "node.h"
2122

2223
namespace {
2324

@@ -93,11 +94,11 @@ TEST(NodeTest, GetUniqueChildDirectory) {
9394
root.children.push_front(file);
9495

9596
EXPECT_EQ(root.GetUniqueChildDirectory(), nullptr);
96-
root.children.pop_front(); // remove file
97+
root.children.pop_front(); // remove file
9798
}
9899

99100
EXPECT_EQ(root.GetUniqueChildDirectory(), &child);
100-
root.children.pop_front(); // remove child
101+
root.children.pop_front(); // remove child
101102
}
102103

103104
EXPECT_EQ(root.GetUniqueChildDirectory(), nullptr);
@@ -122,4 +123,4 @@ TEST(NodeTest, GetStat) {
122123
EXPECT_EQ(st.st_mode, static_cast<mode_t>(S_IFREG | 0755));
123124
}
124125

125-
} // namespace
126+
} // namespace

0 commit comments

Comments
 (0)