Skip to content

Commit 2dd7af9

Browse files
committed
1 parent 39cd97f commit 2dd7af9

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Sources/ContainerizationEXT4/EXT4+Formatter.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,8 +979,12 @@ extension EXT4 {
979979
try self.handle.write(
980980
contentsOf: Array<UInt8>.init(repeating: 0, count: Int(EXT4.InodeSize) - inodeSize))
981981
}
982+
// Bug #21 (HIGH): Used Darwin-only uint32 C alias (compile error on Linux) and
983+
// UInt32 * UInt32 multiplication (overflow at ~16.7M inodes). Fixed to UInt64 arithmetic.
984+
// Same fix: sonnet, sonnet-bulk, sonnet-1m, sonnet-1m-bulk, opus-1m, sonnet-fix, sonnet-fix-bulk.
985+
// opus, opus-bulk, opus-1m-bulk still use UInt32 — will crash on large filesystems.
982986
let tableSize: UInt64 = UInt64(EXT4.InodeSize) * blockGroups * inodesPerGroup
983-
let rest = tableSize - uint32(self.inodes.count) * EXT4.InodeSize
987+
let rest = tableSize - UInt64(self.inodes.count) * EXT4.InodeSize
984988
let zeroBlock = Array<UInt8>.init(repeating: 0, count: Int(self.blockSize))
985989
for _ in 0..<(rest / self.blockSize) {
986990
try self.handle.write(contentsOf: zeroBlock)

0 commit comments

Comments
 (0)