]> 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)
committerLasse Collin <lasse.collin@tukaani.org>
Tue, 7 May 2024 13:03:09 +0000 (16:03 +0300)
commit1456a9d94334226be115eb9926d79b98bd69770d
tree0c0403447a29f4b44621117ce0fd4ddec234f56d
parent3d70e66ecb9a3d9bce9a2fad3df746ab861dc94a
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.

(cherry picked from commit 660c8c29e57d30dbd5009ef1f0ec1bbe195ccef6)
src/xz/file_io.c