Skip to content
Open

Bzip3 #673

Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions archive/bzip3.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
meta:
id: bzip3
title: Bzip3 header
file-extension: bz3
license: LGPL-3.0
encoding: UTF-8
endian: le
doc:
bzip3 is a decompression tool and library. Depending on whether or not the
CLI or the library is used the file format is slightly different. This
specification describes the structure of the format as generated by the CLI
(header and chunks, not blocks).
doc-ref:
- https://github.com/kspalaiologos/bzip3
- https://github.com/kspalaiologos/bzip3/blob/972e6694b815/doc/bzip3_format.md
seq:
- id: header
type: header
- id: blocks
type: compressed_data_block
repeat: until
repeat-until: _io.eof or _.is_last
types:
header:
seq:
- id: signature
contents: 'BZ3v1'
- id: block_size
type: u4
valid:
min: 66560
max: 535822336
compressed_data_block:
seq:
- id: len_compressed
type: u4
- id: len_uncompressed
type: u4
valid:
max: _root.header.block_size
- id: data
size: len_compressed
instances:
is_last:
value: len_uncompressed < _root.header.block_size
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about this? Can you back it up with a link to https://github.com/kspalaiologos/bzip3 as a source, perhaps?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bzip3 doesn't take concatenated files into account but will just try to continue. For my particular use case (where I need to be able to carve) it is actually important. So no, it isn't in the specification.

Copy link
Member

@generalmimon generalmimon May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain this in a doc somewhere why this .ksy spec does this while the reference implementation does not? Because it's confusing at least.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is a bit confusing, and it also doesn't work in all cases (so I need to work a bit more on expanding the specification). Would you prefer if I would first add additional block parsing?