Commit 3dd9d15
committed
gh-153636: Raise InvalidHeaderError for malformed GNU sparse pax numbers in tarfile
When a pax extended header carried a malformed GNU sparse number, tarfile
parsed it with a bare int() and let the resulting ValueError escape to the
caller from _proc_gnusparse_01, _proc_gnusparse_10, and the GNU.sparse.size
and GNU.sparse.realsize branches of _apply_pax_info, unlike the GNU sparse
0.0 handler which already reports such corruption as InvalidHeaderError. Wrap
those conversions so a bad number raises tarfile.InvalidHeaderError, which the
reader treats as end of archive, giving the whole GNU sparse family
consistent behavior on a corrupt header.1 parent 832bc0b commit 3dd9d15
3 files changed
Lines changed: 94 additions & 5 deletions
File tree
- Lib
- test
- Misc/NEWS.d/next/Library
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1647 | 1647 | | |
1648 | 1648 | | |
1649 | 1649 | | |
1650 | | - | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
1651 | 1654 | | |
1652 | 1655 | | |
1653 | 1656 | | |
| |||
1657 | 1660 | | |
1658 | 1661 | | |
1659 | 1662 | | |
1660 | | - | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
1661 | 1667 | | |
1662 | 1668 | | |
1663 | 1669 | | |
1664 | 1670 | | |
1665 | | - | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
1666 | 1675 | | |
1667 | 1676 | | |
1668 | 1677 | | |
| |||
1674 | 1683 | | |
1675 | 1684 | | |
1676 | 1685 | | |
1677 | | - | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
1678 | 1690 | | |
1679 | | - | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
1680 | 1695 | | |
1681 | 1696 | | |
1682 | 1697 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2435 | 2435 | | |
2436 | 2436 | | |
2437 | 2437 | | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
2438 | 2509 | | |
2439 | 2510 | | |
2440 | 2511 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments