1
0
mirror of https://github.com/lz4/lz4.git synced 2026-10-24 01:48:57 +03:00
Commit Graph

186 Commits

Author SHA1 Message Date
Yann Collet
38b3ed8a33 cli: -b --fast=# benchmarks a single level
cLevelLast defaulted to -10000, meaning "unset".
With --fast=# and # > 10000, cLevel is below this sentinel,
so -b benchmarked all levels from -# up to -10000:
--fast=10003 ran 4 benchmarks, --fast=2147483647 ~2 billions.
Use INT_MIN as the sentinel instead.
2026-10-18 11:19:49 -07:00
Akash Deshmukh
3796322233 cli: reject numeric arguments that overflow
readU32FromChar() silently wrapped around on values larger than 32 bits,
and compression levels were then cast to int without a range check.
As a result, out-of-range arguments did something unrelated instead of
failing, for example:

  lz4 --fast=3000000000   compressed at maximum (HC) level
  lz4 -3000000000         used the fastest level (output larger than input)
  lz4 -4294967305         used level 9
  lz4 -B4294967300        used 64 KB blocks
  lz4 -B4194305K          used 1 KB blocks

readU32FromChar() now exits with an error when the value (including
K/M suffixes) overflows 32 bits, and compression level arguments
(-#, -e#, --fast=#) are rejected when larger than INT_MAX.
LZ4_CLEVEL and LZ4_NBWORKERS values that overflow are ignored with the
existing warning, like other invalid values.

Also fix the --fast=0 and --fast=-1 tests in test-lz4-basic.sh: they
used a misspelled file name (dg20K instead of dg20k), so lz4 failed
because the file was missing rather than because of the option.
2026-10-18 11:19:49 -07:00
jlee303
f3aedd1344 add warning message when content size flag is used with stdin 2026-01-21 11:39:34 -08:00
Yann Collet
2719f42eb5 removed year from header (#1605)
as it's a burden to maintain, and wasn't consistently updated.

Now rely on git dating.
2025-04-27 10:55:25 -08:00
Yann Collet
217bdb2f2f update -H documentation regarding compression levels 2024-09-04 11:03:28 -07:00
Yann Collet
9d298e9540 -h only documents -T# when multithreading is enabled
fixes #1480
2024-07-28 21:30:29 -07:00
Yann Collet
4f25e37a75 --list automatically triggers -m 2024-07-14 23:49:57 -07:00
Yann Collet
2db419ee23 removed implicit stdout
fixes #1193.

Implicit `stdout` has been a behavior of the `lz4` cli since its early days,
but it ends up being confusing for users, which do not expect this behavior.

The feature is already deprecated, it has been issuing a warning message for several years.
It's time to cut it out.
2024-07-12 22:24:42 -07:00
Yann Collet
c78899a3a2 add support for environment variable LZ4_CLEVEL 2024-07-08 18:48:11 +02:00
Yann Collet
b7b0ee0a54 Add MT control via Environment variable LZ4_NBWORKERS 2024-07-06 23:04:43 +02:00
Yann Collet
718d1dcad7 warning message when nbThreads above limit 2024-07-06 04:14:39 -07:00
Yann Collet
fab3068680 add test for bug #1374 2024-03-21 23:33:30 -07:00
Yann Collet
7a1b70502a fix variable LZ4IO_MULTITHREAD 2024-03-10 17:57:26 -07:00
Yann Collet
1230f1ca61 regrouped all compile-time variables into programs/lz4conf.h
also:
updated naming scheme for better consistency
2024-01-01 09:49:22 -08:00
Yann Collet
d61b4f1fe2 LZ4IO_MULTITHREADING can be forcefully disabled at compile time 2023-12-31 15:55:53 -08:00
Yann Collet
0d57b8262e Build variable LZ4_NBTHREADS_DEFAULT
can provide a different default nb of threads at compile time.
2023-12-31 00:18:07 -08:00
Yann Collet
6a3932d1c9 make file open errors recoverable in legacy mode 2023-12-29 16:53:58 -08:00
Yann Collet
0dfbe965d6 report nb of threads in verbose mode 2023-12-29 12:50:43 -08:00
Yann Collet
3bdaad3560 silence some clang x32 test
early versions of clang fail on a heisenbug,
on what seems to be a buggy optimizer issue (disappears with -O0).
later versions have even more issue producing basic functioning executables.
this test seems hard to setup.
might not be worth the trouble.
2023-12-29 02:38:21 -08:00
Yann Collet
3227a55269 added a simple test for MT CLI commands
and documented the new command.
2023-12-28 22:32:13 -08:00
Yann Collet
a49ca22195 fix cmake recipe
though it still builds single-threaded lz4
2023-12-28 17:14:15 -08:00
Yann Collet
4984c7fde6 updated Welcome message to specify if binary support multithreading or not 2023-12-28 16:32:32 -08:00
Yann Collet
127fa57895 control over nbThreads
and automatic determination
2023-12-27 23:32:37 -08:00
Yann Collet
8a1c8aa31d first implementation, for compression of legacy format 2023-12-27 23:32:37 -08:00
Yann Collet
839edadd09 Merge pull request #1247 from lz4/fix1246
fix #1246
2023-07-08 04:37:06 -07:00
Yann Collet
bdecb2e803 fix #1246
The resource is being freed anyway, since this is an exit point from `main()`,
but it's proper to release the resource manually first,
and avoids triggering an automated detection tool.
2023-06-30 08:30:25 +02:00
Dimitri Papadopoulos
bdfe4c0c98 Enclose by a do-while loop to avoid possible if/else logic defects 2023-06-25 17:43:51 +02:00
Dominique Pelle
3347485307 fix: various typos 2022-07-31 17:47:00 +02:00
Yann Collet
8f18b4b4e6 introduced new --no-crc command
which disables both frame and block checksums.
2022-07-29 22:22:27 +02:00
Yann Collet
f01b7b5209 can select validation of CRC during benchmark
on command line, using existing long command --no-frame-crc.
Note : it's effectively more than that, since _all_ checksums are disabled.
2022-07-29 22:13:38 +02:00
Yann Collet
4f4d09a0d1 implement decoder-only benchmark mode
requires an LZ4 Frame as input
2022-07-29 19:22:59 +02:00
Yann Collet
49e63cd522 fixed minor leak 2022-07-01 02:55:47 -07:00
Yann Collet
149644df49 fixed -tm
which was broken up to now.
2022-07-01 02:21:44 -07:00
Yann Collet
e23700d263 fix #1086
just remove the specific code of #704, it's not necessary and produces side effects.
2022-07-01 01:45:12 -07:00
Yann Collet
35565bf0dc refactored logic to test special file names 2022-07-01 01:36:32 -07:00
Yann Collet
24b50935f9 fail on requesting to process 3+ file names in legacy mode
warning only if -f is selected.
2022-06-30 21:53:29 -07:00
Yann Collet
573fa33d1d added test
for --list from stdin
2022-01-28 17:08:44 -08:00
WHR
540b52ea7b Allow '--list' with stdin if it is a regular file 2021-12-14 19:41:09 +08:00
Yann Collet
87a80acbe7 updated license & header dates 2020-11-25 14:45:14 -08:00
Yann Collet
36eadb205a all usages of prefs within lz4io are const 2020-11-14 12:40:17 -08:00
Yann Collet
392809d66e fix minor static analyzer warnings
detected by scan-build and cppcheck
fix #786
2020-09-29 17:09:58 -07:00
Filipe Calasans
781417a369 Implement -m option with legacy format on cli 2020-02-07 17:03:13 -08:00
Filipe Calasans
ac4940cd98 Fix lz4cli --list option 2020-02-06 21:39:54 -08:00
Jerome Duval
935b432be1 bring support for Haiku up to date. 2019-11-07 14:32:38 +01:00
Reto Koradi
cc91777c98 Make benchmark compatible with dictionary compression
Support the -D command line option for running benchmarks. The
benchmark code was slightly restructured to factor out the calls
that need to be different for each benchmark scenario. Since there
are now 4 scenarios (all combinations of fast/HC and with/without
dictionary), the logic was getting somewhat convoluted otherwise.

This was done by extending the compressionParameters struct that
previously contained just a single function pointer. It now
contains 4 function pointers for init/reset/compress/cleanup,
with the related state. The functions get a pointer to the
structure as their first argument (inspired by C++), so that they
can access the state values in the struct.
2019-11-05 23:38:00 -08:00
WHR
eee8cc79e7 lz4cli: add option '--best' as an alias of '-12' 2019-07-23 13:37:11 +08:00
Yann Collet
baf9b0e043 fix #734 : --version should output to stdout
instead of stderr
2019-06-24 16:08:30 -07:00
gabrielstedman
729eef61a1 Handle file not existing case #704 2019-05-26 15:04:45 +01:00
gstedman
81081f9b2d List mode improvements.
Improve formatting
  Include static assert
  Use UTIL_fseek to handle potential fseek limitation
  Be explicit when refusing to read from stdin
  Properly free dctx after use
  Include valgrind tests
2019-05-16 20:53:29 +01:00
Yann Collet
ae5cea9112 fixed C90 compliance
re-structure code, have everything into a single section of lz4io.c
2019-04-22 12:27:25 -07:00