]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0042: crypt: cannot decrypt empty file v9.2.0042
authorFoxe Chen <chen.foxe@gmail.com>
Sat, 21 Feb 2026 17:34:20 +0000 (17:34 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 21 Feb 2026 17:34:20 +0000 (17:34 +0000)
Problem:  crypt: cannot decrypt empty file (smss2022)
Solution: Update wrong condition in check_for_cryptkey()
          (Foxe Chen)

fixes:  #19416
closes: #19455

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/fileio.c
src/testdir/test_crypt.vim
src/version.c

index 1f372c39e3c14e3029866e9de005ce33b984bcdf..5851d80b48646de7f5d7d7e1a3bf316048931460 100644 (file)
@@ -3022,7 +3022,7 @@ check_for_cryptkey(
            int header_len;
 
            header_len = crypt_get_header_len(method);
-           if (*sizep <= header_len)
+           if (*sizep < header_len)
                // invalid header, buffer can't be encrypted
                return NULL;
 
index a652357a0f07eb53cd645937644b10d1652f6f45..41118601f9a7f58ed097cc83290984d480e156cc 100644 (file)
@@ -459,4 +459,18 @@ func Test_crypt_set_key_disallow_append_subtract()
   bwipe!
 endfunc
 
+" Test unencrypted an empty file
+func Test_uncrypt_empty()
+  CheckFeature sodium
+
+  let hex =<< trim END
+  00000000: 5669 6d43 7279 7074 7e30 3521 f02f 52ed  VimCrypt~05!./R.
+  00000010: adc3 e5f3 e06c 2fc8 3ce3 ffde d48b 95fe  .....l/.<.......
+  00000020: 341e 74f7 0200 0000 0000 0000 0000 0004  4.t.............
+  00000030: 0000 0000 0200 0000                      ........
+  END
+
+  call Uncrypt_stable_xxd('xchacha20v2', hex, "vim", [""], 0)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 362d7df8579fa942726d8e3f46ddc99c14ae792d..90edccaba7f07c729ad20b50e8a0b2395255d6d2 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    42,
 /**/
     41,
 /**/