From 5d57377d3b1e5719ccef1baabbd1c48ff68861b8 Mon Sep 17 00:00:00 2001 From: 0xf00sec <159052166+0xf00sec@users.noreply.github.com> Date: Mon, 2 Jun 2025 21:01:55 +0000 Subject: Unsafe mem-op in mkfs.hefs. Buffer Overflow and Unsafe memory operations in mkfs.hefs. --- tooling/mkfs.hefs.cc | 287 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 195 insertions(+), 92 deletions(-) diff --git a/tooling/mkfs.hefs.cc b/tooling/mkfs.hefs.cc index fcb0c006..4a9ab4dd 100644 --- a/tooling/mkfs.hefs.cc +++ b/tooling/mkfs.hefs.cc @@ -7,123 +7,226 @@ #include #include #include +#include #include +#include +#include namespace detail { -/// @interal -/// @brief GB equation formula. +/// @internal +/// @brief GB‐to‐byte conversion (use multiplication, not XOR). static constexpr size_t gib_cast(uint32_t gb) { - return ((1024 ^ 3) * gb); + return static_cast(gb) * 1024ULL * 1024ULL * 1024ULL; } } // namespace detail static size_t kDiskSize = detail::gib_cast(4UL); static uint16_t kVersion = kHeFSVersion; -static std::u8string kLabel = kHeFSDefaultVolumeName; +static std::u8string kLabel; static size_t kSectorSize = 512; -/// @brief Entrypoint of tool. -int main(int argc, char** argv) { - if (argc < 2) { - mkfs::console_out() - << "hefs: usage: mkfs.hefs -L