mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-17 15:38:30 +00:00
Support lz4_legacy archive with multiple magic
Multiple lz4_legacy archives can be directly concatenated
This commit is contained in:
parent
12093a3dad
commit
7fcb63230f
@ -454,7 +454,7 @@ private:
|
|||||||
class LZ4_decoder : public chunk_out_stream {
|
class LZ4_decoder : public chunk_out_stream {
|
||||||
public:
|
public:
|
||||||
explicit LZ4_decoder(stream_ptr &&base) :
|
explicit LZ4_decoder(stream_ptr &&base) :
|
||||||
chunk_out_stream(std::move(base), LZ4_COMPRESSED, sizeof(block_sz) + 4),
|
chunk_out_stream(std::move(base), LZ4_COMPRESSED, sizeof(block_sz)),
|
||||||
out_buf(new char[LZ4_UNCOMPRESSED]), block_sz(0) {}
|
out_buf(new char[LZ4_UNCOMPRESSED]), block_sz(0) {}
|
||||||
|
|
||||||
~LZ4_decoder() override {
|
~LZ4_decoder() override {
|
||||||
@ -471,12 +471,14 @@ protected:
|
|||||||
auto in = reinterpret_cast<const char *>(buf);
|
auto in = reinterpret_cast<const char *>(buf);
|
||||||
|
|
||||||
if (block_sz == 0) {
|
if (block_sz == 0) {
|
||||||
if (chunk_sz == sizeof(block_sz) + 4) {
|
memcpy(&block_sz, in, sizeof(block_sz));
|
||||||
// Skip the first 4 bytes, which is magic
|
if (block_sz == 0x184C2102) {
|
||||||
memcpy(&block_sz, in + 4, sizeof(block_sz));
|
// This is actually the lz4 magic, read the next 4 bytes
|
||||||
} else {
|
block_sz = 0;
|
||||||
memcpy(&block_sz, in, sizeof(block_sz));
|
chunk_sz = sizeof(block_sz);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
// Read the next block chunk
|
||||||
chunk_sz = block_sz;
|
chunk_sz = block_sz;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user