RKrahl / archive-tools

Tools for managing archives
Apache License 2.0
1 stars 2 forks source link

Must verify that basedir is a directory when creating an archive with relative paths #9

Closed RKrahl closed 5 years ago

RKrahl commented 5 years ago

When creating an archive with relative paths, all paths must start with basedir. This is verified. But it is not verified that basedir is a directory:

>>> p = Path("msg.txt")
>>> p.is_file()
True
>>> archive = Archive("archive.tar", mode="x:", paths=[p], basedir=p)

This pathologic case even produces a corrupt archive that cannot be extracted:

$ tar tvf archive.tar 
-r--r--r-- rolf/users      262 2019-02-10 21:26 msg.txt/.manifest.yaml
-rw-r--r-- rolf/users        7 2019-02-10 21:13 msg.txt
$ tar xf archive.tar 
tar: msg.txt: Cannot open: File exists
tar: Exiting with failure status due to previous errors