Skip to content

Commit 5d18715

Browse files
authored
gh-107811: tarfile: treat overflow in UID/GID as failure to set it (#108369)
1 parent 72119d1 commit 5d18715

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Lib/tarfile.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2557,7 +2557,8 @@ def chown(self, tarinfo, targetpath, numeric_owner):
25572557
os.lchown(targetpath, u, g)
25582558
else:
25592559
os.chown(targetpath, u, g)
2560-
except OSError as e:
2560+
except (OSError, OverflowError) as e:
2561+
# OverflowError can be raised if an ID doesn't fit in `id_t`
25612562
raise ExtractError("could not change owner") from e
25622563

25632564
def chmod(self, tarinfo, targetpath):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:mod:`tarfile`: extraction of members with overly large UID or GID (e.g. on
2+
an OS with 32-bit :c:type:`!id_t`) now fails in the same way as failing to
3+
set the ID.

0 commit comments

Comments
 (0)