]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
4 years agoRAR5 reader: reject files that declare invalid header flags 1326/head
Grzegorz Antoniak [Sun, 2 Feb 2020 07:04:41 +0000 (08:04 +0100)] 
RAR5 reader: reject files that declare invalid header flags

One of the fields in RAR5's base block structure is the size of the
header. Some invalid files declare a 0 header size setting, which can
confuse the unpacker. Minimum header size for RAR5 base blocks is 7
bytes (4 bytes for CRC, and 3 bytes for the rest), so block size of 0
bytes should be rejected at header parsing stage.

The fix adds an error condition if header size of 0 bytes is detected.
In this case, the unpacker will not attempt to unpack the file, as the
header is corrupted.

The commit also adds OSSFuzz #20459 sample to test further regressions
in this area.

4 years agoMerge pull request #1324 from bradking/solaris-11.4
Martin Matuška [Sat, 1 Feb 2020 18:38:16 +0000 (19:38 +0100)] 
Merge pull request #1324 from bradking/solaris-11.4

libarchive: Fix detection of 'major' on Solaris 11.4

4 years agoFix use after free in ISO9660 and XAR writer
Martin Matuska [Fri, 31 Jan 2020 23:58:03 +0000 (00:58 +0100)] 
Fix use after free in ISO9660 and XAR writer

Remove rbtree nodes before freeing them.
For better code readability import new rbtree macros from NetBSD.

Fixes #1325

4 years agoUpdate filter and format options in manual pages.
Martin Matuska [Thu, 30 Jan 2020 23:30:34 +0000 (00:30 +0100)] 
Update filter and format options in manual pages.

The list of format and filter options in bsdtar(1) is incomplete.
Add reference to manual pages archive_write_set_options(3) and
archive_read_set_options(3) for a complete list of supported options.

Fixes #1323

4 years agomtree reader: initialize checkfs with 0
Martin Matuska [Thu, 30 Jan 2020 23:29:35 +0000 (00:29 +0100)] 
mtree reader: initialize checkfs with 0

4 years agolibarchive: Fix detection of 'major' on Solaris 11.4 1324/head
Brad King [Thu, 30 Jan 2020 14:49:22 +0000 (09:49 -0500)] 
libarchive: Fix detection of 'major' on Solaris 11.4

In `archive_pack_dev.c` there is code checking the `HAVE_MAJOR` macro,
but it is not computed.  Port the equivalent logic from
`archive_entry.c` to define the macro.

4 years agoCmake MSVC: replace warning C4061 with C4062
Martin Matuska [Mon, 27 Jan 2020 23:25:53 +0000 (00:25 +0100)] 
Cmake MSVC: replace warning C4061 with C4062

Fixes #1322

4 years agotest_write_format_xar: add "none" options to test
Martin Matuska [Sun, 26 Jan 2020 00:20:36 +0000 (01:20 +0100)] 
test_write_format_xar: add "none" options to test

4 years agoPAX writer: fix return-on-error memory leaks in archive_write_pax_header()
Martin Matuska [Sun, 26 Jan 2020 00:01:25 +0000 (01:01 +0100)] 
PAX writer: fix return-on-error memory leaks in archive_write_pax_header()

4 years agoPAX writer: fix entry uname or gname longer than 32 characters
Martin Matuska [Sat, 25 Jan 2020 23:35:50 +0000 (00:35 +0100)] 
PAX writer: fix entry uname or gname longer than 32 characters

Fixes #1319

4 years agoUnify unsupported entry file type error message in writer
Martin Matuska [Sat, 25 Jan 2020 13:26:59 +0000 (14:26 +0100)] 
Unify unsupported entry file type error message in writer

Closes #1320

4 years agoXAR writer: fix compression output buffer handling
Martin Matuska [Thu, 23 Jan 2020 15:13:19 +0000 (16:13 +0100)] 
XAR writer: fix compression output buffer handling

Add "none" as acceptable value to xar:checksum and xar:toc-checksum
Document XAR options in bsdtar(1)

Fixes #1317

4 years agoCI: make mingw32-make verbose
Martin Matuska [Wed, 22 Jan 2020 22:30:32 +0000 (23:30 +0100)] 
CI: make mingw32-make verbose

4 years agoAdd printf attributes to the printflike functions used in tests and fix
zoulasc [Tue, 21 Jan 2020 18:34:18 +0000 (13:34 -0500)] 
Add printf attributes to the printflike functions used in tests and fix
the format errors.

Closes #1318

4 years agoRAR5 reader: refactored parse_tables() a little bit
Grzegorz Antoniak [Wed, 1 Jan 2020 06:29:34 +0000 (07:29 +0100)] 
RAR5 reader: refactored parse_tables() a little bit

Some if/continue constructs could be changed to if/elseif/else blocks.
This allows elimination of superfluous 'continue' directives.

Closes #1280

4 years agoUpdate archive_read_support_format_rar5.c
MonkeybreadSoftware [Fri, 22 Nov 2019 11:17:37 +0000 (12:17 +0100)] 
Update archive_read_support_format_rar5.c

A patch to make this compile in older Visual Studio.
Moving variable declaration up for C89 standard.

4 years agoCI: raise error if MinGW tests fail
Martin Matuska [Wed, 22 Jan 2020 16:35:34 +0000 (17:35 +0100)] 
CI: raise error if MinGW tests fail

4 years agoFix error when overwriting files on Windows
Martin Matuska [Wed, 22 Jan 2020 16:13:43 +0000 (17:13 +0100)] 
Fix error when overwriting files on Windows

Introduced in 467d193dd61ca7669a5ba8d38e09836babf64e58

4 years agoFix 7zip_packinfo_digests test when LZMA is not supported
Martin Matuska [Wed, 22 Jan 2020 15:07:12 +0000 (16:07 +0100)] 
Fix 7zip_packinfo_digests test when LZMA is not supported

4 years agocontrib/archivetest: fix compilation under MinGW
Martin Matuska [Wed, 22 Jan 2020 15:06:25 +0000 (16:06 +0100)] 
contrib/archivetest: fix compilation under MinGW

4 years ago7zip reader tests: fixes when LZMA is unsupported
Martin Matuska [Wed, 22 Jan 2020 14:28:08 +0000 (15:28 +0100)] 
7zip reader tests: fixes when LZMA is unsupported

4 years agobsdtar.1: --exclude-vcs sort version control systems and add git
Martin Matuska [Mon, 20 Jan 2020 14:59:25 +0000 (15:59 +0100)] 
bsdtar.1: --exclude-vcs sort version control systems and add git

Fixes #1314

4 years agoAdd test_option_safe_writes to tar tests
Martin Matuska [Mon, 20 Jan 2020 13:23:08 +0000 (14:23 +0100)] 
Add test_option_safe_writes to tar tests

4 years agoImplement ARCHIVE_EXTRACT_SAFE_WRITES on Windows
Martin Matuska [Mon, 20 Jan 2020 10:41:18 +0000 (11:41 +0100)] 
Implement ARCHIVE_EXTRACT_SAFE_WRITES on Windows

As Windows does not support atomic rename/_wrename
we have to unlink the file right before calling _wrename
leaving a short unsafe window where a different file with the
same name can be created and make the rename operation fail.

4 years agoIntroduce archive_write_disk(3) flag ARCHIVE_EXTRACT_SAFE_WRITES
zoulasc [Mon, 20 Jan 2020 12:20:42 +0000 (13:20 +0100)] 
Introduce archive_write_disk(3) flag ARCHIVE_EXTRACT_SAFE_WRITES

This flag changes the way that regular files are extracted:

Instead of removing existing files first and re-creating them in
order to replace their contents, a temporary file is created and
when writing to the temporary file is completed, the file is
rename(2)d to the final destination name.

This has the effect of presenting a consistent view of the file to
the system (either the file with the new contents or the file with
the old contents). Removing and overwriting the file has the
undesired side effect that the the system can either not see the
file at all (from the time it is being removed till the time it is
being re-created), or worse it can see partial file contents. This
is problematic when extracting system files (for example shared
libraries).

If the existing file that is going to be overwritten is a hard link,
for now we unlink it before calling rename(2). This can be done
correctly by creating a hardlink to a tmpnam(3) generated file
and then use rename(2), but that is fairly intrusive and requires
refactoring.

Fixes #1289

4 years agoRAR5 reader: fix unsafe sign check of a bitwise operation.
Martin Matuska [Sat, 18 Jan 2020 00:18:43 +0000 (01:18 +0100)] 
RAR5 reader: fix unsafe sign check of a bitwise operation.

This has no but code correctness effect as cdeque_init() is static
and max_capacity_power_of_2 in our code is always 8192.

Found by LGTM.com code analysis

4 years agoarchive_read.c: remove unnecessary comparsion (iindex is unsigned int)
Martin Matuska [Thu, 16 Jan 2020 23:31:07 +0000 (00:31 +0100)] 
archive_read.c: remove unnecessary comparsion (iindex is unsigned int)

Found by LGTM.com code analysis

4 years agoMerge pull request #1316 from zoulasc/tests
Martin Matuška [Thu, 16 Jan 2020 21:10:04 +0000 (22:10 +0100)] 
Merge pull request #1316 from zoulasc/tests

Various test improvements

4 years agoANSI-C prototypes 1316/head
zoulasc [Thu, 16 Jan 2020 20:34:32 +0000 (15:34 -0500)] 
ANSI-C prototypes

4 years agoAdd missing const
zoulasc [Thu, 16 Jan 2020 20:34:16 +0000 (15:34 -0500)] 
Add missing const

4 years agoAdd missing const
zoulasc [Thu, 16 Jan 2020 20:33:58 +0000 (15:33 -0500)] 
Add missing const

4 years agoAdd missing const
zoulasc [Thu, 16 Jan 2020 20:33:39 +0000 (15:33 -0500)] 
Add missing const

4 years ago- Add the NetBSD-specific config.h
zoulasc [Thu, 16 Jan 2020 20:29:57 +0000 (15:29 -0500)] 
- Add the NetBSD-specific config.h
- Use --help instead of -V when -V exits with non-zero code
- Double the string size to prevent truncation

4 years agoRAR5 and WARC readers: move unnecessary comparsion into a comment
Martin Matuska [Thu, 16 Jan 2020 15:13:40 +0000 (16:13 +0100)] 
RAR5 and WARC readers: move unnecessary comparsion into a comment
RAR5 reader: comment out unreachable code

Found by LGTM.com code analysis

4 years agoarchive_ppmd7.c: avoid possible integer overflow (security)
Martin Matuska [Tue, 14 Jan 2020 15:35:31 +0000 (16:35 +0100)] 
archive_ppmd7.c: avoid possible integer overflow (security)

Found by LGTM.com code analysis

4 years agoMultiple code fixes and optimizations
Martin Matuska [Tue, 14 Jan 2020 13:40:11 +0000 (14:40 +0100)] 
Multiple code fixes and optimizations

archive_read_support_format_rar5.c:
  Bitfield int -> signed int

Archive_write_set_format_iso9660.c:
  Bitfield int -> signed int

archive_write_set_format_xar.c:
  Bitfield int -> signed int

archive_write_set_format_7zip.c:
  Bitfield int -> signed int

archive_read_support_format_xar.c
  Remove useless comparsion

archive_read_support_format_rar.c:
  Fix invalid nested loop break.
  Comment out dead code sections.
  Simplify size comparsions of lensymbol and offsymbol.

archive_read_support_filter_uu.c:
  Remove useless comparsions

archive_read_disk_posix.c:
  Remove useless do-while-zero

Found by LGTM.com code analysis

4 years agoWindows: use _localtime64_s and _gmtime64_s where appropriate
Martin Matuska [Mon, 13 Jan 2020 13:23:00 +0000 (14:23 +0100)] 
Windows: use _localtime64_s and _gmtime64_s where appropriate

4 years agoUnify header style, header guard comes first
Martin Matuska [Mon, 13 Jan 2020 12:28:26 +0000 (13:28 +0100)] 
Unify header style, header guard comes first

Found by LGTM.com code analysis

4 years agoUse localtime_r and gmtime_r if supported
Martin Matuska [Mon, 13 Jan 2020 11:37:32 +0000 (12:37 +0100)] 
Use localtime_r and gmtime_r if supported

Found by LGTM.com code analysis

4 years agoFix erroneous use of archive_string_empty() macro
Martin Matuska [Sun, 12 Jan 2020 07:52:33 +0000 (08:52 +0100)] 
Fix erroneous use of archive_string_empty() macro

Found by LGTM.com code analysis

4 years agoLHA reader UTF16: dirSep must match machine endianess
Martin Matuska [Thu, 9 Jan 2020 11:36:59 +0000 (12:36 +0100)] 
LHA reader UTF16: dirSep must match machine endianess

4 years agoLHA reader UTF-16: Encode directory separator with archive_le16enc()
Martin Matuska [Thu, 9 Jan 2020 09:51:34 +0000 (10:51 +0100)] 
LHA reader UTF-16: Encode directory separator with archive_le16enc()

Wrap to 80 characters.
Fixes #1307

4 years agoMerge pull request #1308 from Claybird/fix_lha_endian
Martin Matuška [Tue, 7 Jan 2020 20:20:23 +0000 (21:20 +0100)] 
Merge pull request #1308 from Claybird/fix_lha_endian

Fixed endian problem in lha UTF-16 encoding.
Fixes #1307

4 years agoFixed endian problem in lha UTF-16 encoding. 1308/head
Claybird [Tue, 7 Jan 2020 13:07:52 +0000 (22:07 +0900)] 
Fixed endian problem in lha UTF-16 encoding.

A patch to fix #1307

4 years agoRedo fix for #1302 in a way that archive_write_client_open()
Martin Matuska [Mon, 6 Jan 2020 02:08:17 +0000 (03:08 +0100)] 
Redo fix for #1302 in a way that archive_write_client_open()
correctly frees its allocations in an error case.

Reverts 5e270715b51d199467195b56f77e21cb8bb1d642

4 years agoMinor style newline consistency fixes
Martin Matuska [Sun, 5 Jan 2020 02:09:34 +0000 (03:09 +0100)] 
Minor style newline consistency fixes

4 years agoImplement archive_write_client_free()
Martin Matuska [Fri, 3 Jan 2020 02:47:19 +0000 (03:47 +0100)] 
Implement archive_write_client_free()

Plugs memory leak of test_open_failure
Fixes #1302

4 years agoAdd mbed TLS as optional crypto provider
Martin Matuska [Thu, 2 Jan 2020 23:24:39 +0000 (00:24 +0100)] 
Add mbed TLS as optional crypto provider

Make Nettle optional and OpenSSL default
Fixes #1301

4 years agoLibarchive 3.4.2dev
Martin Matuska [Mon, 30 Dec 2019 01:16:19 +0000 (02:16 +0100)] 
Libarchive 3.4.2dev

4 years agoLibarchive 3.4.1 v3.4.1
Martin Matuska [Mon, 30 Dec 2019 01:12:32 +0000 (02:12 +0100)] 
Libarchive 3.4.1

4 years agoFix possible off-by-one when dealing with readlink(2)
Pawel Jakub Dawidek [Sun, 22 Dec 2019 00:10:38 +0000 (01:10 +0100)] 
Fix possible off-by-one when dealing with readlink(2)

readlink(2) and readlinkat(2) don't append a null byte to the given buffer.

4 years agoFix a possible heap-buffer-overflow in archive_string_append_from_wcs()
Martin Matuska [Sat, 28 Dec 2019 21:58:08 +0000 (22:58 +0100)] 
Fix a possible heap-buffer-overflow in archive_string_append_from_wcs()

When we grow the archive_string buffer, we have to make sure it fits
at least one maximum-sized multibyte character in the current locale
and the null character.

Fixes #1298

4 years agoMerge pull request #1297 from antekone/bug/GH-1257
Martin Matuška [Sat, 28 Dec 2019 15:31:23 +0000 (16:31 +0100)] 
Merge pull request #1297 from antekone/bug/GH-1257

ZIP reader: support LZMA_STREAM_END marker in 'lzma alone' files

4 years agoZIP reader: support LZMA_STREAM_END marker in 'lzma alone' files 1297/head
Grzegorz Antoniak [Mon, 23 Dec 2019 07:20:28 +0000 (08:20 +0100)] 
ZIP reader: support LZMA_STREAM_END marker in 'lzma alone' files

It appears that ZIPX files with type 14 stream ('lzma alone') can
contain LZMA_STREAM_END markers at the end of the stream. The ZIP reader
was displaying an "unknown error 1" status after encountering such
marker.

The fix handles such case, and the reader doesn't return error status
anymore. Thus it should be possible to unpack files that contain the
LZMA_STREAM_END marker at the end of the stream.

Fixes #1257

4 years agoAdd test for reading 7z archives with Digests in PackInfo
Martin Matuska [Sat, 21 Dec 2019 22:10:37 +0000 (23:10 +0100)] 
Add test for reading 7z archives with Digests in PackInfo

Fixes #1295

4 years ago7z: PackInfo Digests are prefixed by kCRC, not kSize
cielavenir [Thu, 19 Dec 2019 04:10:04 +0000 (13:10 +0900)] 
7z: PackInfo Digests are prefixed by kCRC, not kSize

4 years agoMerge pull request #1296 from antekone/rar5_ossfuzz_19509
Martin Matuška [Sat, 21 Dec 2019 21:19:29 +0000 (22:19 +0100)] 
Merge pull request #1296 from antekone/rar5_ossfuzz_19509

RAR5 reader: verify window size for multivolume archives

4 years agoRAR5 reader: verify window size for multivolume archives 1296/head
Grzegorz Antoniak [Wed, 18 Dec 2019 18:28:12 +0000 (19:28 +0100)] 
RAR5 reader: verify window size for multivolume archives

RAR5 archives can contain files that span across multiple .rar files. If the
archive contains a big file that doesn't fit to first .rar file, then this file
is continued in another .rar file.

In this case, the RAR compressor first emits the FILE base block for this big
file in the first .rar file. Then, it finishes first .rar file, and creates the
new .rar file. In this new file, it emits the continuation FILE block that
marks start of the continuation data for the rest of the huge file.

The problem was that the RAR5 reader didn't ignore the window size declaration
when parsing through the continuation FILE base block. The malicious file could
declare a different window size inside the continuation base block than was
declared in the primary FILE base block in the previous volume. The window size
from continuation block was applied, but the actual window buffer was not
reallocated. This resulted in a potential SIGSEGV error, since bounary checks
for accessing the window buffer were working incorrectly (the window size
variable didn't match the actual window buffer size).

The commit fixes the issue by ignoring the window size declaration in the
continuation FILE base block when switching volumes.

The commit also contains a test case and OSSFuzz sample #19509.

4 years agoMerge pull request #1288 from mmatuska/configurable_xattr_headers
Martin Matuška [Sun, 15 Dec 2019 00:45:12 +0000 (01:45 +0100)] 
Merge pull request #1288 from mmatuska/configurable_xattr_headers

Add the "xattrhdr" option to pax write options.

4 years agoCI: upgrade FreeBSD Cirrus CI images to 12.1 and 11.3
Martin Matuska [Sat, 14 Dec 2019 23:20:51 +0000 (00:20 +0100)] 
CI: upgrade FreeBSD Cirrus CI images to 12.1 and 11.3

4 years agoLHA reader: plug two memory leaks on error
Martin Matuska [Sat, 14 Dec 2019 23:05:40 +0000 (00:05 +0100)] 
LHA reader: plug two memory leaks on error

Reported by: OSS-Fuzz issue 19360, 19362

4 years agoAdd the "xattrhdr" option to pax write options. 1288/head
Martin Matuska [Tue, 3 Dec 2019 00:09:42 +0000 (01:09 +0100)] 
Add the "xattrhdr" option to pax write options.

This allows us to control whether "SCHILY.xattr", "LIBARCHIVE.xattr" or
both headers (default) are written when storing extended attributes.

Document "hdrcharset" option for pax.

4 years agoImplement private state logic for write filters 1287/head
Martin Matuska [Fri, 6 Dec 2019 10:25:19 +0000 (11:25 +0100)] 
Implement private state logic for write filters

This ensures that filters may be opened and closed only once and
__archive_write_filter() may be called only on an open filter.

Refactor filter open code and move logic to archive_write.c

Fixes #351

4 years agoRemove remnants of archive_entry_acl_next_w
Joerg Sonnenberger [Sat, 30 Nov 2019 04:15:27 +0000 (05:15 +0100)] 
Remove remnants of archive_entry_acl_next_w

4 years agoRemove unused variables
Joerg Sonnenberger [Wed, 27 Nov 2019 21:15:11 +0000 (22:15 +0100)] 
Remove unused variables

4 years agoRemove unused variable
Joerg Sonnenberger [Wed, 27 Nov 2019 21:13:21 +0000 (22:13 +0100)] 
Remove unused variable

4 years agoWhen the initial archive open for write fails, explicitly free filters.
Joerg Sonnenberger [Sat, 19 Oct 2019 15:15:05 +0000 (17:15 +0200)] 
When the initial archive open for write fails, explicitly free filters.

This provides a defense-in-depth against programming errors due to the
partial state. Based on a report from Airbus Security - Vulnerability
Management.

4 years agoRefactor archive_write_close_filter logic
Joerg Sonnenberger [Sat, 19 Oct 2019 15:09:11 +0000 (17:09 +0200)] 
Refactor archive_write_close_filter logic

4 years agoarchive_write_filter_compress: free state in free handler
Joerg Sonnenberger [Sat, 19 Oct 2019 14:59:51 +0000 (16:59 +0200)] 
archive_write_filter_compress: free state in free handler

4 years agoLHA reader: ensure that UTF-16 input always has a multiple of 2 bytes
Martin Matuska [Tue, 26 Nov 2019 22:32:31 +0000 (23:32 +0100)] 
LHA reader: ensure that UTF-16 input always has a multiple of 2 bytes

Fixes #1284

4 years agoMerge pull request #1282 from kwojcicki/master
Tim Kientzle [Mon, 25 Nov 2019 22:22:22 +0000 (14:22 -0800)] 
Merge pull request #1282 from kwojcicki/master

Fixing resource cleanup in minitar

4 years agoFixing resource cleanup in minitar 1282/head
Krystian Wojcicki [Sat, 23 Nov 2019 03:42:43 +0000 (22:42 -0500)] 
Fixing resource cleanup in minitar

4 years agoCI: remove Fedora 30 distcheck at Cirrus CI
Martin Matuska [Thu, 21 Nov 2019 22:33:40 +0000 (23:33 +0100)] 
CI: remove Fedora 30 distcheck at Cirrus CI

4 years agoBugfix and optimize archive_wstring_append_from_mbs()
Martin Matuska [Thu, 21 Nov 2019 02:08:40 +0000 (03:08 +0100)] 
Bugfix and optimize archive_wstring_append_from_mbs()

The cal to mbrtowc() or mbtowc() should read up to mbs_length
bytes and not wcs_length. This avoids out-of-bounds reads.

mbrtowc() and mbtowc() return (size_t)-1 wit errno EILSEQ when
they encounter an invalid multibyte character and (size_t)-2 when
they they encounter an incomplete multibyte character. As we return
failure and all our callers error out it makes no sense to continue
parsing mbs.

As we allocate `len` wchars at the beginning and each wchar has
at least one byte, there will never be need to grow the buffer,
so the code can be left out. On the other hand, we are always
allocatng more memory than we need.

As long as wcs_length == mbs_length == len we can omit wcs_length.
We keep the old code commented if we decide to save memory and
use autoexpanding wcs_length in the future.

Fixes #1276

4 years agoHave "make dist" create .tar.gz, .tar.xz and .zip distribution files
Martin Matuska [Wed, 20 Nov 2019 00:42:22 +0000 (01:42 +0100)] 
Have "make dist" create .tar.gz, .tar.xz and .zip distribution files

Fixes #1277

4 years agoWhen opening directories, use O_EXEC flag only on FreeBSD
Martin Matuska [Tue, 19 Nov 2019 15:50:27 +0000 (16:50 +0100)] 
When opening directories, use O_EXEC flag only on FreeBSD

Fixes #1279

4 years agoCI: add distcheck and MacOS build to github actions
Martin Matuska [Mon, 18 Nov 2019 07:12:58 +0000 (08:12 +0100)] 
CI: add distcheck and MacOS build to github actions

4 years agoCI: move Windows MinGW and MSVC builds to GitHub Actions
Martin Matuska [Mon, 18 Nov 2019 01:11:03 +0000 (02:11 +0100)] 
CI: move Windows MinGW and MSVC builds to GitHub Actions

4 years agotest_open_fd: skip error test on GitHub Actions
Martin Matuska [Sun, 17 Nov 2019 23:11:37 +0000 (00:11 +0100)] 
test_open_fd: skip error test on GitHub Actions

4 years agotest_read_format_lha_filename_utf16.c: pass copyright with permission
Martin Matuska [Sun, 17 Nov 2019 23:00:54 +0000 (00:00 +0100)] 
test_read_format_lha_filename_utf16.c: pass copyright with permission

4 years agotest_read_format_lha_filename_utf16.c: add missing condition
Martin Matuska [Sun, 17 Nov 2019 21:57:24 +0000 (22:57 +0100)] 
test_read_format_lha_filename_utf16.c: add missing condition

4 years agoAdd missing testfile to Makefile.am
Martin Matuska [Sun, 17 Nov 2019 21:32:55 +0000 (22:32 +0100)] 
Add missing testfile to Makefile.am

4 years agoMerge pull request #1263 from Claybird/add_unicode_support_on_lha
Martin Matuška [Sun, 17 Nov 2019 21:09:11 +0000 (22:09 +0100)] 
Merge pull request #1263 from Claybird/add_unicode_support_on_lha

Adds UNICODE filename support for reading lha/lzh format

4 years agoFixed bugs in cases that dirname and fname have different codepages. 1263/head
Claybird [Thu, 7 Nov 2019 14:34:29 +0000 (23:34 +0900)] 
Fixed bugs in cases that dirname and fname have different codepages.

4 years agoUpdated test case.
Claybird [Thu, 7 Nov 2019 14:32:53 +0000 (23:32 +0900)] 
Updated test case.

This is to cover cases where dirname and filename have different codepages.

4 years agoFixed unicode escapes in NFD test case.
Claybird [Mon, 4 Nov 2019 08:05:43 +0000 (17:05 +0900)] 
Fixed unicode escapes in NFD test case.

4 years agoFixed test case to support NFD normalization
Claybird [Mon, 4 Nov 2019 07:21:01 +0000 (16:21 +0900)] 
Fixed test case to support NFD normalization

4 years agoAdded a test case on lha with UTF-16 filenames.
Claybird [Mon, 4 Nov 2019 06:01:26 +0000 (15:01 +0900)] 
Added a test case on lha with UTF-16 filenames.

4 years agoFixed broken UTF-16 support on *nix systems.
Claybird [Mon, 4 Nov 2019 05:58:37 +0000 (14:58 +0900)] 
Fixed broken UTF-16 support on *nix systems.

In the broken code, wchar_t was incorrectly assumed to be 16-bit.
This was not a portable way.

Fixed code uses archive_string and codepage information, instead of using archive_wstring.

4 years agoFixed memory leaks
Claybird [Wed, 16 Oct 2019 11:39:42 +0000 (20:39 +0900)] 
Fixed memory leaks

4 years agoThis adds UNICODE filename support for lha.
Claybird [Mon, 14 Oct 2019 13:32:54 +0000 (22:32 +0900)] 
This adds UNICODE filename support for lha.

The lastest lha format supports UNICODE filenames on its content, using extended headers(EXT_UTF16_FILENAME and EXT_UTF16_DIRECTORY).
However, currently libarchive ignores them.
This modification is to handle these extensions.

4 years agoMerge pull request #1260 from danielverkamp/sparse-32bit-overflow
Martin Matuška [Mon, 7 Oct 2019 13:05:53 +0000 (15:05 +0200)] 
Merge pull request #1260 from danielverkamp/sparse-32bit-overflow

Fix sparse file offset overflow on 32-bit systems

4 years agoMerge pull request #1253 from antekone/bug/uninitialized_variable_warnings
Martin Matuška [Mon, 7 Oct 2019 13:02:26 +0000 (15:02 +0200)] 
Merge pull request #1253 from antekone/bug/uninitialized_variable_warnings

RAR5 reader: remove compilation warnings ('uninitialized variable')

4 years agoMerge pull request #1252 from antekone/bug/recheck_solid_window_size2
Martin Matuška [Mon, 7 Oct 2019 13:01:48 +0000 (15:01 +0200)] 
Merge pull request #1252 from antekone/bug/recheck_solid_window_size2

RAR5 reader: verify window size for solid files

4 years agoFix sparse file offset overflow on 32-bit systems 1260/head
Daniel Verkamp [Fri, 4 Oct 2019 19:31:32 +0000 (12:31 -0700)] 
Fix sparse file offset overflow on 32-bit systems

On architectures where ssize_t is 32 bits but file offsets are 64 bits
(such as 32-bit Linux with _FILE_OFFSET_BITS=64), the POSIX disk reader
would incorrectly skip large sparse regions due to a 32-bit integer
overflow in _archive_read_data_block().  This can result in the reader
failing with "Encountered out-of-order sparse blocks", since the
overflowed value is interpreted as a signed number and added to the
current offset.

The bytes variable was used to store the difference between two 64-bit
integers, but bytes is a ssize_t.  Since this value of bytes was not
used after the block handling sparse offsets (it is always overwritten
in the block below), replace it with an int64_t sparse_bytes variable
that can always represent the difference without truncation.

Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
4 years agoLimit #pragma GCC to GCC-compatible cmopilers
Joerg Sonnenberger [Thu, 3 Oct 2019 17:32:44 +0000 (19:32 +0200)] 
Limit #pragma GCC to GCC-compatible cmopilers

4 years agozip writer: don't append unused NUL for directories
Joerg Sonnenberger [Wed, 2 Oct 2019 10:21:20 +0000 (12:21 +0200)] 
zip writer: don't append unused NUL for directories

This can result in a heap overflow dependening on the buffer allocation.
Simplify the path length calculation and avoid binary operands.

Based on PR #1255 from Will Wagner

4 years agoRAR5 reader: verify window size for solid files 1252/head
Grzegorz Antoniak [Fri, 27 Sep 2019 05:38:58 +0000 (07:38 +0200)] 
RAR5 reader: verify window size for solid files

RAR5 archives can contain files compressed independently of each other,
and files that share a common window buffer, so files which are
compressed using 'solid' method. In the latter case, all files
are required to use the same window buffer, so window size should also
be the same.

OSSFuzz sample #15482 declares a different window size for multiple
solid files. RAR5 reader doesn't reallocate window buffer when
decompressing solid files, so it was possible to perform an
out-of-bounds read by declaring two solid files, where the second solid
file declared the window size parameter that was bigger than window size
used in first solid file.

This commit introduces additional checks to ensure all solid files are
using the same window size.

The commit also adds a test case using OSSFuzz sample #15482 to hunt
down regressions in the future.

Some other test cases had to be adjusted as well, because other OSSFuzz
samples were also declaring different window sizes for solid files. So
this commit has changed the error reporting for those invalid sample files.

4 years agoRAR5 reader: remove compilation warnings ('uninitialized variable') 1253/head
Grzegorz Antoniak [Fri, 27 Sep 2019 05:48:21 +0000 (07:48 +0200)] 
RAR5 reader: remove compilation warnings ('uninitialized variable')

This commit makes the compiler happy by removing some uninitialized
variable warnings/errors in RAR5 reader.

4 years agoMerge pull request #1250 from ischwarze/ischwarze-mdoc
Martin Matuška [Tue, 24 Sep 2019 20:26:09 +0000 (22:26 +0200)] 
Merge pull request #1250 from ischwarze/ischwarze-mdoc

Minor corrections to the formatting of manual pages