]> git.ipfire.org Git - thirdparty/libarchive.git/commit
Handle all negative int64_t values in mtree/tar 1542/head
authorSamanta Navarro <ferivoz@riseup.net>
Tue, 1 Jun 2021 11:25:03 +0000 (11:25 +0000)
committerSamanta Navarro <ferivoz@riseup.net>
Tue, 1 Jun 2021 11:25:03 +0000 (11:25 +0000)
commitf2b582881d622db623ae2700008225fd1a007663
tree3099a420fe2925e4ee858b99ef720a65c1e96670
parent5bb998d869979140156bce59c0ff8f9063a25581
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.
libarchive/archive_read_support_format_mtree.c
libarchive/archive_read_support_format_tar.c