From 0b4a8074e52cbe374b54b2ca0a810dde3cfe9723 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 13 Jan 2024 21:41:27 +0100 Subject: [PATCH] minor fixes --- src/posix_storage.cpp | 4 ++-- src/torrent_peer.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/posix_storage.cpp b/src/posix_storage.cpp index 4ce84cf7720..ed8f7c813df 100644 --- a/src/posix_storage.cpp +++ b/src/posix_storage.cpp @@ -476,9 +476,9 @@ namespace aux { // reading and writing, but doesn't create the file. "w+" creates // the file and truncates it #ifdef TORRENT_WINDOWS - f = ::_wfopen(convert_to_native_path_string(fn).c_str(), L"wb+"); + f = ::_wfopen(convert_to_native_path_string(fn).c_str(), mode_str); #else - f = std::fopen(fn.c_str(), "wb+"); + f = std::fopen(fn.c_str(), mode_str); #endif if (f == nullptr) { diff --git a/src/torrent_peer.cpp b/src/torrent_peer.cpp index 9bf75e4a0e4..5cf72763025 100644 --- a/src/torrent_peer.cpp +++ b/src/torrent_peer.cpp @@ -85,10 +85,12 @@ namespace libtorrent { { if (e1.port() > e2.port()) swap(e1, e2); - std::uint32_t p; - auto ptr = reinterpret_cast(&p); + std::array buf; + auto ptr = buf.data(); aux::write_uint16(e1.port(), ptr); aux::write_uint16(e2.port(), ptr); + std::uint32_t p; + std::memcpy(&p, buf.data(), 4); ret = crc32c_32(p); } else if (aux::is_v6(e1))