import Foundation

final class MVitaPtpMessageInConfirm:MVitaPtpMessageIn
{
    let code:UInt16
    let transactionId:UInt32
    
    override init?(
        header:MVitaPtpMessageInHeader,
        data:Data)
    {
        let codeSize:Int = MemoryLayout<UInt16>.size
        let transactionSize:Int = MemoryLayout<UInt32>.size
        let expectedSize:Int = codeSize + transactionSize
        
        guard
            
            data.count >= expectedSize
            
        else
        {
            return nil
        }
        
        let rangeTransaction:Range<Data.Index> = Range<Data.Index>(
            codeSize ..< data.count)
        let subdataTransaction:Data = data.subdata(in:rangeTransaction)
        
        guard
            
            let code:UInt16 = data.valueFromBytes(),
            let transactionId:UInt32 = subdataTransaction.valueFromBytes()
            
        else
        {
            return nil
        }
        
        self.code = code
        self.transactionId = transactionId
        
        super.init(
            header:header,
            data:data)
    }
}

import Foundation

final class MVitaPtpMessageInConfirm:MVitaPtpMessageIn
{
    let code:UInt16
    let transactionId:UInt32
    
    override init?(
        header:MVitaPtpMessageInHeader,
        data:Data)
    {
        let codeSize:Int = MemoryLayout<UInt16>.size
        let transactionSize:Int = MemoryLayout<UInt32>.size
        let expectedSize:Int = codeSize + transactionSize
        
        guard
            
            data.count == expectedSize
            
        else
        {
            return nil
        }
        
        let rangeTransaction:Range<Data.Index> = Range<Data.Index>(
            codeSize ..< data.count)
        let subdataTransaction:Data = data.subdata(in:rangeTransaction)
        
        guard
            
            let code:UInt16 = data.valueFromBytes(),
            let transactionId:UInt32 = subdataTransaction.valueFromBytes()
            
        else
        {
            return nil
        }
        
        self.code = code
        self.transactionId = transactionId
        
        super.init(
            header:header,
            data:data)
    }
}

--- 
+++ 
@@ -15,7 +15,7 @@
         
         guard
             
-            data.count == expectedSize
+            data.count >= expectedSize
             
         else
         {
Allow confirm data to be greater
