File tree Expand file tree Collapse file tree
Sources/ContainerizationEXT4 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -267,7 +267,9 @@ extension EXT4 {
267267 continue
268268 }
269269 let rawName = buffer [ i..< endIndex]
270- let name = String ( bytes: rawName, encoding: . ascii) !
270+ guard let name = String ( bytes: rawName, encoding: . ascii) else {
271+ throw Error . nonAsciiXattrName
272+ }
271273 let valueStart = Int ( xattrEntry. valueOffset) + offset
272274 let valueEnd = Int ( xattrEntry. valueOffset) + Int( xattrEntry. valueSize) + offset
273275 let value = [ UInt8] ( buffer [ valueStart..< valueEnd] )
@@ -290,6 +292,7 @@ extension EXT4 {
290292 case insufficientSpace( _ inode: Int )
291293 case malformedXattrBuffer
292294 case convertAsciiString( _ s: String )
295+ case nonAsciiXattrName
293296 case missingXAttrHeader
294297
295298 public var description : String {
@@ -300,6 +303,8 @@ extension EXT4 {
300303 return " malformed extended attribute buffer "
301304 case . convertAsciiString( let s) :
302305 return " cannot convert string \( s) to a list of ASCII characters "
306+ case . nonAsciiXattrName:
307+ return " extended attribute name contains non-ASCII bytes "
303308 case . missingXAttrHeader:
304309 return " missing header for extended attribute entry "
305310 }
You can’t perform that action at this time.
0 commit comments