Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrupt files hang in makemargin! #32

Open
maleadt opened this issue Jun 17, 2024 · 0 comments
Open

Corrupt files hang in makemargin! #32

maleadt opened this issue Jun 17, 2024 · 0 comments

Comments

@maleadt
Copy link

maleadt commented Jun 17, 2024

MWE:

using CodecBzip2: transcode, Bzip2Compressor, Bzip2Decompressor

function main()
    compressed = UInt8[0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0x54, 0x32, 0x62, 0x1a, 0x00, 0x02, 0x98, 0xdf, 0x9a, 0xde, 0x90, 0x40, 0x7f, 0xff, 0xe6, 0x3f, 0x7f, 0xdf, 0xc0, 0xff, 0xff, 0xff, 0xfa, 0x04, 0x00, 0x40, 0x20, 0x04, 0x00, 0x00, 0x08, 0x50, 0x03, 0xbe, 0x5d, 0xce, 0xee, 0x68, 0xe7, 0x5d, 0xcb, 0xb5, 0x2c, 0x34, 0x49, 0x91, 0xa1, 0xa2, 0x30, 0xa7, 0xa9, 0xfa, 0x53, 0x6a, 0x68, 0xcd, 0x13, 0x40, 0xc4, 0xf5, 0x00, 0x68, 0x00, 0x00, 0x68, 0x1a, 0x0d, 0x11, 0x3d, 0x13, 0x14, 0xcd, 0x53, 0xd4, 0xfd, 0x22, 0x69, 0xa0, 0xda, 0x86, 0x83, 0x40, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x02, 0x50, 0x40, 0x53, 0x29, 0xea, 0x78, 0xa1, 0xa2, 0x7e, 0x94, 0xf5, 0x06, 0x9b, 0x53, 0x40, 0x03, 0x40, 0x34, 0x34, 0x00, 0xd1, 0x90, 0xf5, 0x34, 0x1c, 0x68, 0xc9, 0x91, 0x84, 0x62, 0x01, 0x84, 0xd0, 0x60, 0x13, 0x41, 0xa0, 0x64, 0xc9, 0xa3, 0x26, 0x43, 0x08, 0x0c, 0x24, 0x94, 0xd0, 0x14, 0xf2, 0x4f, 0x49, 0xe9, 0x32, 0x7a, 0x40, 0x68, 0x00, 0x03, 0x40, 0xd3, 0x40, 0x1a, 0x7a, 0x8d, 0x34, 0x06, 0x81, 0xdd, 0x94, 0x18, 0x53, 0x07, 0xf4, 0xa0, 0xc1, 0x2a, 0x64, 0xd0, 0x80, 0x95, 0x30, 0x5b, 0x67, 0x61, 0x08, 0x80, 0x1e, 0x48, 0x73, 0x00, 0x30, 0x0b, 0x03, 0xfd, 0x38, 0xcf, 0x2c, 0x52, 0x96, 0x4c, 0x66, 0x50, 0x17, 0x01, 0x80, 0xa2, 0x22, 0xa6, 0x8e, 0x55, 0x61, 0x3a, 0x0c, 0x18, 0x21, 0xaa, 0xa8, 0xf5, 0x5c, 0x87, 0x99, 0xe0, 0xa7, 0x61, 0xd6, 0x32, 0x08, 0x9a, 0x03, 0xd0, 0xc9, 0x8b, 0x5c, 0x07, 0xb0, 0x48, 0x6c, 0x43, 0x23, 0x3b, 0x37, 0x90, 0xf2, 0xbd, 0x2a, 0x90, 0x3e, 0xe6, 0x11, 0x26, 0x42, 0x19, 0xe7, 0xbf, 0x91, 0xbe, 0x30, 0x20, 0xd6, 0xfd, 0xb4, 0x59, 0x14, 0x36, 0x34, 0x54, 0x8f, 0x87, 0x08, 0x4b, 0xbd, 0x3a, 0x66, 0xa3, 0x25, 0x70, 0x41, 0x76, 0x9d, 0xa1, 0x4e, 0x68, 0xb1, 0x19, 0x76, 0x67, 0x58, 0x8a, 0xad, 0x24, 0x21, 0x39, 0xc5, 0x8f, 0x72, 0x13, 0x41, 0xa8, 0x37, 0x39, 0x45, 0xe4, 0xd1, 0xe7, 0x02, 0x15, 0xba, 0x7a, 0xc6, 0x11, 0x9f, 0x6c, 0xc5, 0x90, 0x0b, 0x0b, 0xc4, 0xc9, 0x39, 0x25, 0x7c, 0x7d, 0xea, 0xd0, 0x95, 0xcd, 0xec, 0x17,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0x33, 0x01, 0xf1, 0x13, 0x2f, 0x31, 0x24, 0x41, 0x35, 0x20, 0x8a, 0x66, 0x5a, 0x14, 0x78, 0x24, 0x92, 0x1e, 0x76, 0x60, 0x1b, 0x2e, 0xcc, 0xdf, 0xc1, 0xd4, 0x9a, 0xc8, 0x2d, 0x6e, 0xcf, 0x42, 0xaa, 0xb6, 0xcf, 0x15, 0x6a, 0x4c, 0x52, 0xd2, 0x21, 0x2d, 0xa8, 0xe8, 0x4b, 0x2f, 0x9c, 0x5e, 0xa4, 0xa9, 0x16, 0x31, 0x89, 0x74, 0x0b, 0x04, 0x47, 0x11, 0xa7, 0x46, 0x1a, 0xe1, 0x4c, 0xe4, 0xa9, 0x12, 0x26, 0x99, 0x0b, 0x9d, 0x8a, 0xd6, 0x0f, 0xbb, 0x9c, 0xbe, 0xa6, 0x92, 0x28, 0x67, 0x47, 0xb6, 0xbd, 0x07, 0x04, 0xa2, 0x05, 0x5c, 0x6e, 0x91, 0x42, 0x43, 0x0c, 0x9a, 0x00, 0x95, 0x14, 0x51, 0xa4, 0x54, 0x90, 0x71, 0x84, 0x80, 0xe7, 0x04, 0x95, 0x0b, 0x69, 0x51, 0xb6, 0x7f, 0x5b, 0x64, 0x9b, 0xd9, 0x5d, 0xb5, 0x60, 0x38, 0xd2, 0x5f, 0xe2]

    mktempdir() do dir
        path = joinpath(dir, "test.bz2")
        write(path, compressed)
        proc = run(ignorestatus(`bunzip2 $path`))
    end

    uncompressed = transcode(Bzip2Decompressor, compressed)
    String(uncompressed)
end

This (corrupt) archive makes the decompressor hang:

^CERROR: InterruptException:
Stacktrace:
 [1] makemargin!(buf::TranscodingStreams.Buffer, minsize::Int64; eager::Bool)
   @ TranscodingStreams ~/.julia/packages/TranscodingStreams/F7ot4/src/buffer.jl:130
 [2] makemargin!
   @ ~/.julia/packages/TranscodingStreams/F7ot4/src/buffer.jl:130 [inlined]
 [3] unsafe_transcode!(output::TranscodingStreams.Buffer, codec::Bzip2Decompressor, input::TranscodingStreams.Buffer)
   @ TranscodingStreams ~/.julia/packages/TranscodingStreams/F7ot4/src/transcode.jl:153
 [4] transcode!
   @ ~/.julia/packages/TranscodingStreams/F7ot4/src/transcode.jl:129 [inlined]
 [5] transcode
   @ ~/.julia/packages/TranscodingStreams/F7ot4/src/transcode.jl:108 [inlined]
 [6] transcode
   @ ~/.julia/packages/TranscodingStreams/F7ot4/src/transcode.jl:107 [inlined]
 [7] transcode(::Bzip2Decompressor, ::Vector{UInt8})
   @ TranscodingStreams ~/.julia/packages/TranscodingStreams/F7ot4/src/transcode.jl:191
 [8] transcode(::Type{Bzip2Decompressor}, args::Vector{UInt8})
   @ TranscodingStreams ~/.julia/packages/TranscodingStreams/F7ot4/src/transcode.jl:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant