#943751 lz4: LZ4_*_destSize() fix for debian lz4 stable versions

Package:
lz4
Source:
lz4
Description:
Fast LZ compression algorithm library - tool
Submitter:
Gao Xiang
Date:
2019-11-01 08:45:03 UTC
Severity:
normal
#943751#5
Date:
2019-10-29 06:47:42 UTC
From:
To:
Hi maintainer,

I'd like to use LZ4 LZ4_*_destSize() apis in debian.

In particular, I'd like to introduce erofs-utils package to debian,
(erofs is a read-only compression file system providing high
performance [1]), which relies on LZ4_*_destSize(), but there are
some stable fixes for these apis in lz4 1.9.0 and 1.9.2, and lz4
upstream doesn't have stable branch for old versions.

Could you kindly considering backporting them to debian lz4 stable
versions for erofs userspace stuffs to use?

merged in lz4-1.9.0
lz4hc.c: change (length >> 8) to (length / 255)
https://github.com/lz4/lz4/commit/660d21272e4c8a0f49db5fc1e6853f08713dff82

merged in lz4-1.9.2
[LZ4_compress_destSize] Allow 2 more bytes of match length
https://github.com/lz4/lz4/commit/690009e2c2f9e5dcb0d40e7c0c40610ce6006eda

[LZ4_compress_destSize] Fix rare data corruption bug
https://github.com/lz4/lz4/commit/6bc6f836a18d1f8fd05c8fc2b42f1d800bc25de1

[LZ4_compress_destSize] Fix overflow condition
https://github.com/lz4/lz4/commit/13a2d9e34ffc4170720ce417c73e396d0ac1471a

[LZ4_compress_destSize] Fix off-by-one error in fix
https://github.com/lz4/lz4/commit/7c32101c655d93b61fc212dcd512b87119dd7333

[LZ4_compress_destSize] Fix off-by-one error
https://github.com/lz4/lz4/commit/d7cad81093cd805110291f84d64d385557d0ffba

since there are some new reports (as follows) for lz4 1.9.2 so I'm not sure
lz4 1.9.2 is stable enough so I think backporting the above fixes is better.
https://github.com/lz4/lz4/issues/783

Here is our unoffical branch merged above patches based on lz4 1.8.3:
https://github.com/erofs/lz4

[1] https://lore.kernel.org/r/20191024033259.GA2513@hsiangkao-HP-ZHAN-66-Pro-G1/

Thanks,
Gao Xiang

#943751#10
Date:
2019-11-01 08:41:05 UTC
From:
To:
Here is a bug reproducer for this issue, please consider backporting
them... It has real affect on *_destSize lz4 users.

bug.c (crash if liblz4 < 1.9.2)

#include <lz4.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

#define SRCSIZE		1045934

int main(void)
{

	int SrcSize = SRCSIZE;
	char buf[SRCSIZE] = {0};
	char dst[4096];
	int compressed;

	compressed = LZ4_compress_destSize(buf, dst, &SrcSize, 4096);
	printf("compressed: %d SrcSize: %d", compressed, SrcSize);
	return 0;
}