Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Sources/ContainerizationEXT4/EXT4+Xattrs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ extension EXT4 {
continue
}
let rawName = buffer[i..<endIndex]
let name = String(bytes: rawName, encoding: .ascii)!
guard let name = String(bytes: rawName, encoding: .ascii) else {
throw Error.nonAsciiXattrName
}
let valueStart = Int(xattrEntry.valueOffset) + offset
let valueEnd = Int(xattrEntry.valueOffset) + Int(xattrEntry.valueSize) + offset
let value = [UInt8](buffer[valueStart..<valueEnd])
Expand All @@ -290,6 +292,7 @@ extension EXT4 {
case insufficientSpace(_ inode: Int)
case malformedXattrBuffer
case convertAsciiString(_ s: String)
case nonAsciiXattrName
case missingXAttrHeader

public var description: String {
Expand All @@ -300,6 +303,8 @@ extension EXT4 {
return "malformed extended attribute buffer"
case .convertAsciiString(let s):
return "cannot convert string \(s) to a list of ASCII characters"
case .nonAsciiXattrName:
return "extended attribute name contains non-ASCII bytes"
case .missingXAttrHeader:
return "missing header for extended attribute entry"
}
Expand Down
Loading