patch 9.2.0042: crypt: cannot decrypt empty file
Commit:
https://github.com/vim/vim/commit/16403b02a04e40e03657c2458b3df6976a4a5a70
Author: Foxe Chen <[email protected]>
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 <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
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,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1vtr2N-006955-RH%40256bit.org.