MacPaw/XADMaster

Rar Split Files cannot be extracted if enabled "Encrypt file names" in windows RAR

kasimok opened this issue · 3 comments

tested with windows rar version 6.0.1, if we select 'split into volumes', set password and check "Encrypt file names", the out put files cannot be extracted.

Capture2

Capture3

I attached the sample: Extract the zip file you will get 2 rar split volumes, their password is 'password'
RAR_Archive_Sample.zip

@PaulTaykalo looks this bug is caused by readMasterHeaderFromHandle function.
`+(RAR5HeaderBlock)readMasterHeaderFromHandle:(CSHandle *)handle
{
RAR5HeaderBlock header;

RAR5Block block;
block.outerstart=0;

@try
{
    CSHandle * signatureSearchingHandle = [handle subHandleToEndOfFileFrom:0];
    NSData * data = [signatureSearchingHandle readDataOfLengthAtMost:RAR5MaximumSFXHeader];
    off_t signatureLocation = [XADRAR5Parser signatureLocationInData:data];
    if (signatureLocation == RAR5SignatureNotFound) {
        [NSException raise:RAR5SignatureCannotBeFound format:@"Signature cannot be found %@",[self class]];
    }
    
    [handle skipBytes:signatureLocation];
    [handle skipBytes:8];
    if([handle atEndOfFile]) return ZeroHeaderBlock;

    block.crc=[handle readUInt32LE];
    block.headersize=ReadRAR5VInt(handle);
    block.start=[handle offsetInFile];
    block.type=ReadRAR5VInt(handle);
    block.flags=ReadRAR5VInt(handle);
    
    if(block.flags&0x0001) block.extrasize=ReadRAR5VInt(handle);
    else block.extrasize=0;
    
    header.archiveFlags=ReadRAR5VInt(handle);
    
    if(block.flags&0x0002) block.datasize=ReadRAR5VInt(handle);
    else block.datasize=0;
}
@catch(id e) { return ZeroHeaderBlock; }

// If first block wasn't main.  !!!!BUG HERE
if (block.type != RAR5HeaderTypeMain) {
    return ZeroHeaderBlock;
}

block.fh=handle;

header.block = block;
return header;

}`

We are expecting a main archive header right after the rar5 signature, however if set 'Encrypt file names' in winrar. There is a archive encryption header between the signature and main archive header. See RAR TECH NOTE.

General archive layout
Self-extracting module (optional)
RAR 5.0 signature
Archive encryption header (optional)
Main archive header
Archive comment service header (optional)

File header 1
Service headers (NTFS ACL, streams, etc.) for preceding file (optional).
...
File header N
Service headers (NTFS ACL, streams, etc.) for preceding file (optional).

Recovery record (optional).
End of archive header.

The code assumes first block is main archive header and stops parsing the rest.

@kasimok not actual? :)

@kasimok not actual? :)

NO. I checked the issues list and found few reply from the author, so I closed this issue.