Loading ...
Sorry, an error occurred while loading the content.

Re: Bug: writing encrypted file, while asked for password, destroys contents

Expand Messages
  • Christian Brabandt
    ... Err, yes that was what I meant. I think this patch does it: iff --git a/src/fileio.c b/src/fileio.c ... +++ b/src/fileio.c @@ -2926,9 +2926,15 @@ int
    Message 1 of 12 , Aug 19 12:38 PM
    • 0 Attachment
      On Do, 15 Aug 2013, Bram Moolenaar wrote:

      > Christian Brabandt wrote:
      > > Wouldn't it be a good idea, to have the file set readonly for as long it
      > > hasn't been encrypted (e.g. the current windows behaviour)?
      >
      > You mean, until it has been decrypted. That makes sense.
      > Actually, when a file is encrypted and the user just hits enter and the
      > prompt for the key, it should also be marked as readonly.

      Err, yes that was what I meant.

      I think this patch does it:

      iff --git a/src/fileio.c b/src/fileio.c
      --- a/src/fileio.c
      +++ b/src/fileio.c
      @@ -2926,9 +2926,15 @@
      int *did_ask; /* flag: whether already asked for key */
      {
      int method = crypt_method_from_magic((char *)ptr, *sizep);
      + int b_p_ro = curbuf->b_p_ro;

      if (method >= 0)
      {
      + /* prevent nasty side-effects by e.g.
      + * FocusLeave autocommands, trying to write the file
      + * or the user accidently hitting enter on the password
      + * prompt and accidently writing the file */
      + curbuf->b_p_ro = TRUE;
      set_crypt_method(curbuf, method);
      if (method > 0)
      (void)blowfish_self_test();
      @@ -2977,6 +2983,7 @@
      *sizep -= CRYPT_MAGIC_LEN + salt_len + seed_len;
      mch_memmove(ptr, ptr + CRYPT_MAGIC_LEN + salt_len + seed_len,
      (size_t)*sizep);
      + curbuf->b_p_ro = b_p_ro; /* resetting ro flag */
      }
      }
      /* When starting to edit a new file which does not have encryption, clear


      regards,
      Christian
      --
      Wenn du etwas Gl├╝ck dein Eigen nennst, verheimliche es.
      -- Saul Bellow

      --
      --
      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 vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Bram Moolenaar
      ... Thanks, I ll look into it. Your diff lost a d .... -- ... /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net /// sponsor
      Message 2 of 12 , Aug 20 2:30 PM
      • 0 Attachment
        Christian Brabandt wrote:

        > On Do, 15 Aug 2013, Bram Moolenaar wrote:
        >
        > > Christian Brabandt wrote:
        > > > Wouldn't it be a good idea, to have the file set readonly for as long it
        > > > hasn't been encrypted (e.g. the current windows behaviour)?
        > >
        > > You mean, until it has been decrypted. That makes sense.
        > > Actually, when a file is encrypted and the user just hits enter and the
        > > prompt for the key, it should also be marked as readonly.
        >
        > Err, yes that was what I meant.
        >
        > I think this patch does it:

        Thanks, I'll look into it.

        Your "diff" lost a "d"....

        --
        From "know your smileys":
        |-( Contact lenses, but has lost them

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ an exciting new programming language -- http://www.Zimbu.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --
        --
        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 vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      Your message has been successfully submitted and would be delivered to recipients shortly.