]> git.ipfire.org Git - thirdparty/xz.git/commit
xz: Windows: Don't (de)compress to special files like "con" or "nul".
authorLasse Collin <lasse.collin@tukaani.org>
Thu, 21 Sep 2023 23:33:29 +0000 (02:33 +0300)
committerJia Tan <jiat0218@gmail.com>
Tue, 31 Oct 2023 10:44:59 +0000 (18:44 +0800)
commit660c8c29e57d30dbd5009ef1f0ec1bbe195ccef6
treeed16e46c14efd606681d0c0bc198c3723147cc85
parentb7ce6e80786fc0c08ed129e8ee262ea96a5473a1
xz: Windows: Don't (de)compress to special files like "con" or "nul".

Before this commit, the following writes "foo" to the
console and deletes the input file:

    echo foo | xz > con_xz
    xz --suffix=_xz --decompress con_xz

It cannot happen without --suffix because names like con.xz
are also special and so attempting to decompress con.xz
(or compress con to con.xz) will already fail when opening
the input file.

Similar thing is possible when compressing. The following
writes to "nul" and the input file "n" is deleted.

    echo foo | xz > n
    xz --suffix=ul n

Now xz checks if the destination is a special file before
continuing. DOS/DJGPP version had a check for this but
Windows (and OS/2) didn't.
src/xz/file_io.c