gh-107811: tarfile: treat overflow in UID/GID as failure to set it (#108369)

This commit is contained in:
Petr Viktorin 2023-08-23 20:00:07 +02:00 committed by GitHub
parent 72119d16a5
commit 5d18715765
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -2557,7 +2557,8 @@ class TarFile(object):
os.lchown(targetpath, u, g)
else:
os.chown(targetpath, u, g)
except OSError as e:
except (OSError, OverflowError) as e:
# OverflowError can be raised if an ID doesn't fit in `id_t`
raise ExtractError("could not change owner") from e
def chmod(self, tarinfo, targetpath):

View File

@ -0,0 +1,3 @@
:mod:`tarfile`: extraction of members with overly large UID or GID (e.g. on
an OS with 32-bit :c:type:`!id_t`) now fails in the same way as failing to
set the ID.