]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-42369: Fix thread safety of zipfile._SharedFile.tell (GH-26974)
authorKevin Mehall <km@kevinmehall.net>
Sun, 20 Mar 2022 14:26:09 +0000 (08:26 -0600)
committerGitHub <noreply@github.com>
Sun, 20 Mar 2022 14:26:09 +0000 (16:26 +0200)
commite730ae7effe4f13b24f1b5fb1fca005709c86acb
treeb0391ac70889fdde5ce0f2ec8de7acfa1cebb5c1
parent3af68fc77c528d4e7749046cf6e41fd79902e6e6
bpo-42369: Fix thread safety of zipfile._SharedFile.tell (GH-26974)

The `_SharedFile` tracks its own virtual position into the file as
`self._pos` and updates it after reading or seeking. `tell()` should
return this position instead of calling into the underlying file object,
since if multiple `_SharedFile` instances are being used concurrently on
the same file, another one may have moved the real file position.
Additionally, calling into the underlying `tell` may expose thread
safety issues in the underlying file object because it was called
without taking the lock.
Lib/zipfile.py
Misc/NEWS.d/next/Library/2022-03-19-19-56-04.bpo-42369.Ok828t.rst [new file with mode: 0644]