haiku: working USB backend, symlink-safe extraction
- usb_haiku.cpp: each disk device transaction kept minimal, because
Haiku R1/beta6 rejects or hangs on combined ones: erase foreign
content, delete old MBR partitions, create the 0x0c partition
("FAT 32-bit, LBA-mapped", with "active false" parameters) and format
FAT32 are separate commits; Uninitialize is never used on an MBR
- OPENPU_DEBUG=1 traces the Haiku disk device steps on stderr
- extractTar resolves the destination first: SECURE_SYMLINKS refused
destinations under a symlink (/tmp on Haiku)
- check.sh: clang-tidy skips sources not built on Linux
- validated in the Haiku VM: write-usb on the virtual stick gives an MBR,
a FAT32 partition at 1 MiB, the label, license/ and the archive tree
without UpdateInfo.xml, with identical checksums; 53 unit tests pass
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WDASLCiN764v685boRVYar
This commit is contained in:
1 parent
b2ca454d44
commit
962343f220
4 files changed
+103
-16
No files matched your search
+11
-3
@@ -186,13 +186,21 @@ std::uint64_t tarPayloadSize(const fs::path& path)
|
||||
return total;
|
||||
}
|
||||
|
||||
void extractTar(const fs::path& path, const fs::path& destination, const ArchiveProgressCallback& onProgress,
|
||||
void extractTar(const fs::path& path, const fs::path& requestedDestination, const ArchiveProgressCallback& onProgress,
|
||||
const CancelToken* cancel)
|
||||
{
|
||||
std::error_code ec;
|
||||
fs::create_directories(destination, ec);
|
||||
fs::create_directories(requestedDestination, ec);
|
||||
if (ec)
|
||||
throw ArchiveError(ArchiveError::Kind::Io, "cannot create " + destination.string() + ": " + ec.message());
|
||||
throw ArchiveError(ArchiveError::Kind::Io,
|
||||
"cannot create " + requestedDestination.string() + ": " + ec.message());
|
||||
// ARCHIVE_EXTRACT_SECURE_SYMLINKS rejects a symlink anywhere in the target path, including the
|
||||
// destination itself (e.g. /tmp is a symlink on Haiku). Resolve the destination first so that
|
||||
// only links *inside* it are refused.
|
||||
const fs::path destination = fs::canonical(requestedDestination, ec);
|
||||
if (ec)
|
||||
throw ArchiveError(ArchiveError::Kind::Io,
|
||||
"cannot resolve " + requestedDestination.string() + ": " + ec.message());
|
||||
|
||||
ReadPtr a = openTar(path);
|
||||
WritePtr w(archive_write_disk_new());
|
||||
|
||||
Reference in new issue
Block a user