Commit 9c5df0b
authored
Fix GNU long-name extension stream corruption on validation error (#434)
In prepare_header_path, the GNU long-name extension entry was written to
the stream before validating the truncated path via
set_truncated_path_for_gnu_header. If validation failed (e.g., the
truncated path contained '..'), the extension entry was already committed
to the stream with no rollback. The Builder remained usable, so
subsequent writes succeeded — but their data got associated with the
orphaned long-name path, silently corrupting the archive.
Fix by moving the truncation and validation above the append() call.
Since set_truncated_path_for_gnu_header only writes to the in-memory
header buffer (not the stream), reordering is safe.
Also audited prepare_header_link — it does not have this issue because
link names allow all path components (ParentDir, RootDir, etc.) and
there is no post-append validation step.1 parent 88b1e3b commit 9c5df0b
2 files changed
+48
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
756 | 756 | | |
757 | 757 | | |
758 | 758 | | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | 759 | | |
765 | 760 | | |
766 | 761 | | |
767 | 762 | | |
768 | 763 | | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
769 | 768 | | |
770 | 769 | | |
771 | 770 | | |
772 | 771 | | |
773 | 772 | | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
774 | 778 | | |
775 | 779 | | |
776 | 780 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1787 | 1787 | | |
1788 | 1788 | | |
1789 | 1789 | | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
0 commit comments