Commit: patch 9.2.0042: crypt: cannot decrypt empty file

1 view
Skip to first unread message

Christian Brabandt

unread,
Feb 21, 2026, 12:46:49 PM (2 days ago) Feb 21
to vim...@googlegroups.com
patch 9.2.0042: crypt: cannot decrypt empty file

Commit: https://github.com/vim/vim/commit/16403b02a04e40e03657c2458b3df6976a4a5a70
Author: Foxe Chen <chen...@gmail.com>
Date: Sat Feb 21 17:34:20 2026 +0000

patch 9.2.0042: crypt: cannot decrypt empty file

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...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/fileio.c b/src/fileio.c
index 1f372c39e..5851d80b4 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -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;

diff --git a/src/testdir/test_crypt.vim b/src/testdir/test_crypt.vim
index a652357a0..41118601f 100644
--- a/src/testdir/test_crypt.vim
+++ b/src/testdir/test_crypt.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 362d7df85..90edccaba 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 42,
/**/
41,
/**/
Reply all
Reply to author
Forward
0 new messages