intel / QATzip

Compression Library accelerated by Intel® QuickAssist Technology
https://developer.intel.com/quickassist
Other
140 stars 51 forks source link

test: fix overflow on large files #76

Closed iomartin closed 1 year ago

iomartin commented 1 year ago

If the input is a large file and we allocate memory via malloc, we can cause an overflow when computing the comp_out_sz and decomp_out_sz (lines 4247 and 4250):

test_arg[i].comp_out_sz = test_arg[i].src_sz * 2;
test_arg[i].decomp_out_sz = test_arg[i].src_sz * 5;

This would cause the associated mallocs to fail with ENOMEM.

Fix this by using size_t.

Also fix many other places where the variables from test_arg are copied into other variables.

Signed-off-by: Martin Oliveira martin.oliveira@eideticom.com

cfzhu commented 1 year ago

@iomartin , Very thanks for your patch, we will merge this patch in internal repo firstly and update to this repo when next release.

cfzhu commented 1 year ago

Update https://github.com/intel/QATzip/commit/753636457f944f6d3c30500070228d8f453bd6a6