]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(tar): fix lz4 extraction on non-Linux systems
authorVladimír Marek <vlmarek13@gmail.com>
Thu, 18 Jun 2026 19:12:40 +0000 (19:12 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 18 Jun 2026 19:12:40 +0000 (19:12 +0000)
Patch 9.2.0306 fixed malformed lz4 extraction commands by using "tar -I lz4"
on Linux and leaving non-Linux tar implementations to auto-detect lz4 input.
That still fails on systems where tar does not support either -I lz4 or
automatic lz4 decompression, such as Solaris /usr/bin/tar.

Keep the existing Linux path using GNU tar's "-I lz4" support.  For non-Linux
systems, use lz4 explicitly to decompress the archive to stdout and feed the
resulting tar stream to the configured tar extraction command.  This is the
same style tar.vim already used for lz4 archives before patch 9.2.0306.

Follow-up for #19925

closes: #20555

Signed-off-by: Vladimír Marek <vlmarek13@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/autoload/tar.vim

index 3c899f85f66a7fbf99509829f0710c939cc35d15..7f8e24ac0f27775d6cf8e722322a8f02fc2604a3 100644 (file)
@@ -26,6 +26,7 @@
 "   2026 Apr 15 by Vim Project: fix more path traversal issues (#19981)
 "   2026 Apr 16 by Vim Project: use g:tar_secure in tar#Extract()
 "   2026 May 14 by Vim Project: use correct shellescape() call in Vimuntar()
+"   2026 Jun 16 by Vim Project: fix lz4 extraction on non-linux systemd (#20555)
 "
 "      Contains many ideas from Michael Toren's <tar.vim>
 "
@@ -129,7 +130,7 @@ let g:tar_leading_pat='\m^\%([.]\{,2\}/\)\+'
 fun! s:Msg(func, severity, msg)
   redraw!
   if a:severity =~? 'error'
-    echohl Error 
+    echohl Error
   else
     echohl WarningMsg
   endif
@@ -733,8 +734,10 @@ fun! tar#Extract()
   elseif tarball =~# "\.tlz4$"
    if has("linux")
     let extractcmd= substitute(extractcmd,"-","-I lz4 -","")
+    call system(extractcmd." ".shellescape(tarball)." ".g:tar_secure.shellescape(fname))
+   else
+    call system("lz4 --decompress --stdout -- ".shellescape(tarball)." | ".extractcmd." - ".g:tar_secure.shellescape(fname))
    endif
-   call system(extractcmd." ".shellescape(tarball)." ".g:tar_secure.shellescape(fname))
    if v:shell_error != 0
     call s:Msg('tar#Extract', 'error', $"{extractcmd} {tarball} {fname}: failed!")
    else
@@ -744,8 +747,10 @@ fun! tar#Extract()
   elseif tarball =~# "\.tar\.lz4$"
    if has("linux")
     let extractcmd= substitute(extractcmd,"-","-I lz4 -","")
+    call system(extractcmd." ".shellescape(tarball)." ".g:tar_secure.shellescape(fname))
+   else
+    call system("lz4 --decompress --stdout -- ".shellescape(tarball)." | ".extractcmd." - ".g:tar_secure.shellescape(fname))
    endif
-   call system(extractcmd." ".shellescape(tarball)." ".g:tar_secure.shellescape(fname))
    if v:shell_error != 0
     call s:Msg('tar#Extract', 'error', $"{extractcmd} {tarball} {fname}: failed!")
    else