Skip to content

Invalid TAR end #62

@kevinresol

Description

@kevinresol
import format.tar.*;
import haxe.io.*;

using Lambda;

class Main {
    static function main() {
        function file(name:String, bytes:Bytes) return {
            fileName: name,
            fileSize: bytes.length,
            fileTime: Date.now(),
            fmod: 666,
            uid: 1,
            gid: 1,
            uname: 'u',
            gname: 'g',
            data: bytes,
        }
        
        var data = [
            file('folder/file1.txt', Bytes.alloc(4096)), // fails if: 1024, 2048, 4096, 512000, etc...
            file('folder/file2.txt', Bytes.alloc(1)),
        ].list();
        
        var output = new BytesOutput();
        new Writer(output).write(data);
        var entries = new Reader(new BytesInput(output.getBytes())).read();
        for(file in entries) trace(file.fileName, file.fileSize);
    }
}

Trying to tar some files, if the first file size is of some magic numbers, it fails to untar with Invalid TAR end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions