Unportable left shift reported with MKSANITIZER=yes
USE_SANITIZER=undefined:
# progress -zf ./games.tgz tar -xp -C "./" -f -
/public/src.git/usr.bin/gzip/gzip.c:2126:33: runtime error: left shift of
251 by 24 places cannot be represented in type 'int'
100%
|****************************************************************************************************************|
44500 KiB 119.69 MiB/s 00:00 ETA
Refactor the following code into something that is more clear
and fix signed integer shift, by casting all buf[] elements to
(unsigned int):
unsigned char buf[8];
uint32_t usize;
[...]
else {
usize = buf[4] | buf[5] << 8 |
buf[6] << 16 | buf[7] << 24;
[...]
New version:
usize = buf[4];
usize |= (unsigned int)buf[5] << 8;
usize |= (unsigned int)buf[6] << 16;
usize |= (unsigned int)buf[7] << 24;
Only the "<< 24" part needs explicit cast, but for consistency make the
integer promotion explicit and clear to a code reader.
Sponsored by <The NetBSD Foundation>
Obtained from: NetBSD (CVS rev. 1.113)
MFC after: 1 week
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.
The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
No functional change intended.
allows scripts to distinguish it between real fatal errors, for instance a
CRC mismatch.
Update manual page for the behavior change.
PR: bin/203873
Submitted by: Eugene Grosbein <eugen grosbein net>
MFC after: 2 weeks
in PATH_MAX + 1 bytes from the file. In r281500, strrchr() is
used to strip possible path portion of the file name to mitigate
a possible attack. Unfortunately, strrchr() expects a buffer
that is NUL-terminated, and since we are processing potentially
untrusted data, we can not assert that be always true.
Solve this by reading in one less byte (now PATH_MAX) and
explicitly terminate the buffer after the read size with NUL.
Reported by: Coverity
CID: 1264915
X-MFC-with: 281500
MFC after: 13 days
When we are operating on a symbolic link pointing to an existing
file, bail out by default, but go ahead if -f is specified.
Submitted by: arundel
MFC after: 2 weeks
not optimal from a performance standpoint since the write buffer is
not necessarily be filled up when the inflate rountine reached the
end of input buffer and it's not the end of file.
This problem gets uncovered by trying to pipe gunzip -c output to
a GEOM device directly, which enforces the writes be multiple of
sector size.
Sponsored by: iXsystems, Inc.
Reported by: jpaetzel
MFC after: 2 weeks
handler, as the latter is not guaranteed to be signal safe, and we
do not really care about flushing the stream during SIGINT.
Suggested by: Maxim Konovalov <maxim.konovalov gmail com>
MFC after: 13 days
- Limit suffix to be no more than 30 bytes long. This matches GNU
behavior.
- Correct usage of memcpy().
Note that this commit only corrects the stack underflow issue, we
still need some other fixes to cover other edges. [1]
Reported by: Ron Jude <ronj wytheville org>
Discussed with: Matthew Green (original NetBSD gzip author),
Eygene Ryabinkin <rea-fbsd codelabs ru> [1]
Approved by: re (kib)
- gzip -n does not store timestamp; [1]
- Reduce diff against NetBSD by moving some casts in our local
versions.
PR: bin/134955
Obtained from: NetBSD
MFC after: 1 month
in some commercial Unix systems, which utilizes Huffman minimum redundancy
code tree to compress files. This implementation supports the "new" pack
format only, just like GNU gzip did.
Thanks for oliver@'s archive set which I can test against, and Mingyan Guo
for providing helpful review of my code.
PR: bin/109567
MFC after: 1 month
- Reduce scope where return value can be referenced.
- Add a dummy access to timestamp to silence warning.
Submitted by: Mingyan Guo <guomingyan gmail com>
target file after the timestamp has been set; otherwise setting the
timestamp will fail if the flags don't permit it (i.e., uchg).
MFC after: 1 week
PR: 120208
Submitted by: Ighighi <ighighi at gmail.com>
being output in verbose mode when doing recursive[1].
- Use better representation of S:
PR: bin/114470
Submitted by: Ighighi <ighighi gmail com> [1]
Approved by: re (hrs)
NetBSD version is a feature-to-feature re-implementation of GNU
gzip using the freely-redistributable zlib and this version is
expected to be mostly bug-to-bug compatible with the GNU
implementation.
- Because this is a piece of mature code and we want to make
changes so it is added directly rather than importing to
src/contrib.
- Connect newly added code to src/usr.bin/ and rescue/rescue
build.
- Disconnect the GNU gzip code from build for now, they will
be eventually removed completely.
- Provide two new src.conf(5) knobs, WITHOUT_BZIP2_SUPPORT and
WITHOUT_BZIP2.
Tested by: kris (full exp-7 pointyhat build)
Approved by: core (importing a 4-clause BSD licensed file)
Approved by: re (adding new utility during -HEAD code slush)