Hi,

2015/2/14 Sat 6:04:00 UTC+9 Bram Moolenaar wrote:
> Ben Fritz wrote:
> 
> > On Friday, February 13, 2015 at 4:16:01 AM UTC-6, might1 wrote:
> > > At 2015-02-13 18:00:32,"might1" <mig...@126.com> wrote:
> > > > Right now, I just tried vim7.4 downloaded from www.vim.org.
> > >  According to your way, I tried in commanld line 'vim -u NONE -N 
> > > test.txt'   and  'gvim -u NONE -N test.txt' to encrypt with blowfish 
> > > method, both failed. The resulting files all growed to 113MB. Really 
> > > strange! No error jumped out.
> > > 
> > > Do you need I attach the resulting encrypted file whose size remains 
> > > 113MB after max compression? 
> > > 
> > 
> > Actually, attaching the already encrypted file is pretty much useless.
> > 
> > I experimented some, with the attached toy input file (compressed with 
> > 7-zip to avoid a huge attachment), and found that the issue seems to be 
> > related to writing *new* files somehow.
> > 
> > If I create an encrypted output file as follows, everything works fine:
> > 
> > :e encrypt_in.txt
> > :saveas encrypt_blowfish2.txt
> > :X
> > password
> > password
> > :w
> > 
> > However, if I encrypt as follows, I see the E381 error repeated a bunch of 
> > times, and Vim seems to hang if I quit that error and try the password 
> > again and write, presumably creating that giant file the OP mentioned:
> > 
> > :r encrypt_in.txt
> > ggdd
> > :X
> > password
> > password
> > :w encrypt_blowfish2.txt
> > 
> > Oddly enough, this also fails:
> > 
> > :r encrypt_in.txt
> > ggdd
> > :w encrypt_blowfish2.txt
> > :X
> > password
> > password
> > :w
> > 
> > But this succeeds (after a really long time):
> > 
> > :r encrypt_in.txt
> > ggdd
> > :w encrypt_blowfish2.txt
> > :e
> > :X
> > password
> > password
> > :w
> > 
> > It seems to be related to encrypting the swapfile for the new file. This 
> > fails:
> > 
> > :set swapfile noundofile
> > :r encrypt_in.txt
> > ggdd
> > :X
> > password
> > password
> > :w encrypt_blowfish2.txt
> > 
> > But this succeeds:
> > 
> > :set noswapfile undofile
> > :r encrypt_in.txt
> > ggdd
> > :X
> > password
> > password
> > :w encrypt_blowfish2.txt
> > 
> > Using the following Vim version on Windows 7:
> > 
> > VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb  4 2015 10:16:41)
> > MS-Windows 64-bit GUI version with OLE support
> > Included patches: 1-608
> 
> [...]
> 
> Since it works fine on Linux, could it be related to "long" not being
> able to store a pointer?  It's a common problem for porting a C program
> to Windows.

Perhaps I found a fix for this.

--- a/src/memfile.c
+++ b/src/memfile.c
@@ -1033,7 +1033,7 @@
 
 #ifdef FEAT_CRYPT
     /* Decrypt if 'key' is set and this is a data block. */
-    if (*mfp->mf_buffer->b_p_key != NUL)
+    if (*mfp->mf_buffer->b_p_key != NUL || mfp->mf_old_key != NULL)
        ml_decrypt_data(mfp, hp->bh_data, offset, size);
 #endif
 
@@ -1136,7 +1136,7 @@
 
 #ifdef FEAT_CRYPT
     /* Encrypt if 'key' is set and this is a data block. */
-    if (*mfp->mf_buffer->b_p_key != NUL)
+    if (*mfp->mf_buffer->b_p_key != NUL || mfp->mf_old_key != NULL)
     {
        data = ml_encrypt_data(mfp, data, offset, size);
        if (data == NULL)


I checked this only on Windows (but not well).
I hope someone check this more deeply.
I wonder why the problem doesn't occur on Linux.

Regards,
Ken Takata

-- 
-- 
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to