Skip to content

Commit

Permalink
pythongh-107811: tarfile: treat overflow in UID/GID as failure to set…
Browse files Browse the repository at this point in the history
… it (python#108369)
  • Loading branch information
encukou authored Aug 23, 2023
1 parent 72119d1 commit 5d18715
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2557,7 +2557,8 @@ def chown(self, tarinfo, targetpath, numeric_owner):
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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 5d18715

Please sign in to comment.