6 Commits
Author SHA1 Message Date
Samanta Navarro fe83fc33da Added test case for ustar directory handling
Based on test_compat_tar_hardlink.c and with input by Tim Kientzle.
2021-09-05 11:54:48 +00:00
Samanta Navarro 12d74cff72 Ignore size of directories with regular type
In old tar formats directories are specified by appending a slash to
their names.

Directories may have sizes, but they do not have data blocks. Keep this
in mind and avoid skipping data blocks when encountering directories.
2021-09-04 11:56:30 +00:00
Samanta Navarro a7ce8a6aa7 Fix size_t cast in read_mac_metadata_blob
The size_t data type on 32 bit systems is smaller than int64_t. Check
the int64_t value before casting to size_t. If the value is too large
then stop operation instead of continuing operation with truncated
value.
2021-08-28 11:58:20 +00:00
Samanta Navarro 87afe31463 Fix mutual check in tar sparse handling
GNU.sparse.numbytes and GNU.sparse.offset both have to be set before
gnu_add_sparse_entry can be called.

The GNU.sparse.numbytes parser checks for tar->sparse_numbytes.
This has to be tar->sparse_offset instead to work just like the
GNU.sparse.offset parser.
2021-06-01 11:26:45 +00:00
Samanta Navarro a80614384e Fix typos
Typos found with codespell
2021-06-01 11:26:14 +00:00
Samanta Navarro f2b582881d Handle all negative int64_t values in mtree/tar
The variable last_digit_limit is negative since INT64_MIN itself is
negative as well. This means that the last digit after "limit" always
leads to maxval.

Turning last_digit_limit positive in itself is not sufficient because
it would lead to a signed integer overflow during shift operation.

If limit is reached and the last digit is last_digit_limit, the number
is at least maxval. The already existing if condition for even larger
(or smaller) values can be reused to prevent the last shift.

In my humble opinion it might make sense to reduce duplicated code and
keep it separated in a utility source file for shared use.
2021-06-01 11:25:03 +00:00