| Commit message (Collapse) | Author | Files | Lines |
|
main() initialises progName by copying argv[0] with strncpy before argc
is examined. When the program is started with an empty argument vector
(argc == 0 and argv[0] == NULL), for example through
execve(path, (char*[]){ NULL }, envp), this dereferences a NULL pointer
and bzip2recover crashes with SIGSEGV before any argument checking
happens.
Guard the use of argv[0] and fall back to a hard coded "bzip2recover"
string, mirroring the fix already applied to bzip2.c in commit
af79253677ad ("bzip2.c: Check argc >= 1 && argv[0] != NULL").
|
|
When getting an early EOF bsWr is never closed so any buffered output
is leaked and never flushed out to the file.
|
|
This makes sure to cleanup all the memory used and opened file
descriptors.
With this fix valgrind shows no more "leaked" file descriptors or
memory when run with --leak-check=full --show-leak-kinds=all
--track-fds=yes on a valid bzip2 file.
|
|
Posix getc requires setting errno on read error. But it isn't required
to clear errno when reporting EOF. So explicitly set errno to zero
before calling getc to make sure we see the difference between a read
error and a regular EOF.
|
|
Make sure the end of the current block is actually larger than the
start of the current block. Then check the difference is big
enough. This prevents a possible unsigned underflow.
|
|
Update the format specifier for unsigned long long in bzip2recover.c to use
the standard %llu instead of %Lu. Modern compilers (such as Clang) emit a format
warning when using the non-standard %Lu modifier.
Fixes:
bzip2recover.c:376:59: warning: length modifier 'L' results in undefined behavior or no effect with 'u' conversion specifier [-Wformat]
376 | fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT
| ^~~~~~~~~~~~~~~
bzip2recover.c:40:29: note: expanded from macro 'MaybeUInt64_FMT'
40 | # define MaybeUInt64_FMT "%Lu"
| ~^~
bzip2recover.c:376:59: note: did you mean to use 'll'?
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
|
|
There is an off-by-one in the check before calling tooManyBlocks. This
causes the scanning loop to run one more time and cause a possible
read or write one past the global bStart, bEnd, rbStart and rbEnd
buffers. There are no known exploits of this issue and you will need
to compile with something like gcc -fsanitize=address (ASAN
AddressSanitizer) to observe the faulty read/write.
This has been assigned CVE-2026-42250.
|
|
This should never happen, but if there is no, or a NULL argv[0] then
use a hard coded string "bzip2" when calling copyFileName to define
progNameReally.
https://sourceware.org/bugzilla/show_bug.cgi?id=33046
|
|
This helps C++ compilers that come with their own standard library
headers that don't expect to be included inside of extern "C" {...}.
https://sourceware.org/bugzilla/show_bug.cgi?id=32812
|
|
Casting to Int32 or int could create negative values. Which isspace
and isdigit don't handle. SEI CERT C Coding Standard STR37-C.
Resolve by casting to UChar or unsigned char instead of Int32 or int.
https://sourceware.org/bugzilla/show_bug.cgi?id=28283
|
|
We try to be smart in sendMTFValues by initializing just nGroups
number of elements instead of all BZ_N_GROUPS elements. But this means
the compiler doesn't know all elements are correctly initialized and
might warn. The arrays are really small, BZ_N_GROUPS, 6 elements. And
nGroups == BZ_N_GROUPS is the common case. So just initialize them all
always. Using a constant loop might also help the compiler to optimize
the initialization.
https://sourceware.org/bugzilla/show_bug.cgi?id=28904
|
|
This makes sure all commands show up as bold in the man pages.
Suggested-by: Helge Kreutzmann <debian@helgefjell.de>
|
|
STDERR_FILENO is *nix specific and is not defined under MSVC.
So define it using _fileno(stderr).
Suggested-by: Dmitry Tsarevich <dimhotepus@gmail.com>
|
|
GCC10 -fanalyzer notices that we try to call functions that are not
signal safe from our fatal signal handler:
bzip2.c: In function ‘mySIGSEGVorSIGBUScatcher’:
bzip2.c:819:7: warning: call to ‘fprintf’ from within signal handler
[CWE-479] [-Wanalyzer-unsafe-call-within-signal-handler]
It also notices we then call showFileNames and cleanupAndFail which
also call possibly not signal safe functions.
Just write out the error message directly to STDERR and exit without
trying to clean up any files.
|
|
BZ_SEQUENCE_ERROR can be returned if BZ2_bzDecompress is called after
an earlier call already returned BZ_STREAM_END.
Reported-by: Vanessa McHale <vamchale@gmail.com>
|
|
And remove both pages from the repository since the will now be
generated by make dist. Also don't try to update them in
prepare-release.sh script.
|
|
Bug-Debian: https://bugs.debian.org/517257
|
|
Author: Bjarni Ingi Gislason
Bug-Debian: https://bugs.debian.org/675380
|
|
|
|
|
|
Otherwise the generated HTML will have a different randomly generated
name id which generates spurious diffs.
|
|
The bzgrep wrapper always returns 0 as exit code when working on
multiple archives, even when the pattern is not found.
Fix from openSUSE by Kristýna Streitová <kstreitova@suse.com>
https://bugzilla.suse.com/970260
|
|
bzgrep uses ${var//} which is a bashism.
Replace by calling sed so other POSIX shells work.
Patch from openSUSE by Led <ledest@gmail.com>
|
|
The bzdiff script doesn't contain enough quotes, so that it doesn't
work if the TMPDIR environment variable is defined and contains
spaces.
https://bugs.debian.org/493710
Author: Vincent Lefevre <vincent@vinc17.org>
|
|
Keep Julian's email as author information, but redirect general
project feedback in the code and manual to the community mailinglist.
|
|
|
|
But ignore any larger than the theoretical maximum, BZ_MAX_SELECTORS.
The theoretical maximum number of selectors depends on the maximum
blocksize (900000 bytes) and the number of symbols (50) that can be
encoded with a different Huffman tree. BZ_MAX_SELECTORS is 18002.
But the bzip2 file format allows the number of selectors to be encoded
with 15 bits (because 18002 isn't a factor of 2 and doesn't fit in
14 bits). So the file format maximum is 32767 selectors.
Some bzip2 encoders might actually have written out more selectors
than the theoretical maximum because they rounded up the number of
selectors to some convenient factor of 8.
The extra 14766 selectors can never be validly used by the decompression
algorithm. So we can read them, but then discard them.
This is effectively what was done (by accident) before we added a
check for nSelectors to be at most BZ_MAX_SELECTORS to mitigate
CVE-2019-12900.
The extra selectors were written out after the array inside the
EState struct. But the struct has extra space allocated after the
selector arrays of 18060 bytes (which is larger than 14766).
All of which will be initialized later (so the overwrite of that
space with extra selector values would have been harmless).
|
|
The bzip2 command line would report 'not a normal file' for files of
size larger than 2^32 - 1 bytes.
Patch bzip2.c to use _stati64 instead of _stat so that a successful
result is returned for large files.
Resolves https://github.com/philr/bzip2-windows/issues/3.
|
|
Also update the version number in the Makefile comments.
And update any date ranges to include the current year.
|
|
Changes the include path separator for Windows builds to use "/" instead
of "\". Windows has no problems with using a forward slash as a path
separator, but using a backslash causes problems when attempting to
cross compile for other platforms (for example, when trying to cross
compile for MinGW from Linux).
|