Repository navigation
Commit 769d44c
_FileInFile.read() (used by TarFile.extractfile() for seekable-mode
archives) called the underlying compressed fileobj's read() directly.
If a member's compressed payload was corrupted after the header had
already been read successfully, the codec's own exception (zlib.error,
OSError from bz2, lzma.LZMAError, or zstd.ZstdError) would leak straight
through instead of being wrapped in tarfile.ReadError, unlike the
existing streaming-mode (r|gz etc.) code path in _Stream, which already
handles this correctly via a self.exception attribute set per codec.
Give TarFile (and _FileInFile) the same per-codec exception attribute,
set by gzopen/xzopen/zstopen to the specific error type (bz2 already
matches the OSError class default), and wrap the read() call in
_FileInFile with it.
---------
Signed-off-by: Jason Mak <squrrielbro@gmail.com>
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
1 parent 197d332 commit 769d44c
3 files changed
Lines changed: 90 additions & 3 deletions
File tree
- Lib
- test
- Misc/NEWS.d/next/Library
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
665 | 665 | | |
666 | 666 | | |
667 | 667 | | |
668 | | - | |
| 668 | + | |
| 669 | + | |
669 | 670 | | |
670 | 671 | | |
671 | 672 | | |
672 | 673 | | |
673 | 674 | | |
674 | 675 | | |
| 676 | + | |
675 | 677 | | |
676 | 678 | | |
677 | 679 | | |
| |||
748 | 750 | | |
749 | 751 | | |
750 | 752 | | |
751 | | - | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
752 | 757 | | |
753 | 758 | | |
754 | 759 | | |
| |||
771 | 776 | | |
772 | 777 | | |
773 | 778 | | |
774 | | - | |
| 779 | + | |
| 780 | + | |
775 | 781 | | |
776 | 782 | | |
777 | 783 | | |
| |||
1801 | 1807 | | |
1802 | 1808 | | |
1803 | 1809 | | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
1804 | 1816 | | |
1805 | 1817 | | |
1806 | 1818 | | |
| |||
2046 | 2058 | | |
2047 | 2059 | | |
2048 | 2060 | | |
| 2061 | + | |
2049 | 2062 | | |
2050 | 2063 | | |
2051 | 2064 | | |
| |||
2068 | 2081 | | |
2069 | 2082 | | |
2070 | 2083 | | |
| 2084 | + | |
2071 | 2085 | | |
2072 | 2086 | | |
2073 | 2087 | | |
| |||
2124 | 2138 | | |
2125 | 2139 | | |
2126 | 2140 | | |
| 2141 | + | |
2127 | 2142 | | |
2128 | 2143 | | |
2129 | 2144 | | |
| |||
2159 | 2174 | | |
2160 | 2175 | | |
2161 | 2176 | | |
| 2177 | + | |
2162 | 2178 | | |
2163 | 2179 | | |
2164 | 2180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1204 | 1204 | | |
1205 | 1205 | | |
1206 | 1206 | | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
1207 | 1273 | | |
1208 | 1274 | | |
1209 | 1275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments