|
Karsten Hopp |
bbb847 |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
bbb847 |
Subject: Patch 7.4.009
|
|
Karsten Hopp |
bbb847 |
Fcc: outbox
|
|
Karsten Hopp |
bbb847 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
bbb847 |
Mime-Version: 1.0
|
|
Karsten Hopp |
bbb847 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
bbb847 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
bbb847 |
------------
|
|
Karsten Hopp |
bbb847 |
|
|
Karsten Hopp |
bbb847 |
Patch 7.4.009
|
|
Karsten Hopp |
bbb847 |
Problem: When a file was not decrypted (yet), writing it may destroy the
|
|
Karsten Hopp |
bbb847 |
contents.
|
|
Karsten Hopp |
bbb847 |
Solution: Mark the file as readonly until decryption was done. (Christian
|
|
Karsten Hopp |
bbb847 |
Brabandt)
|
|
Karsten Hopp |
bbb847 |
Files: src/fileio.c
|
|
Karsten Hopp |
bbb847 |
|
|
Karsten Hopp |
bbb847 |
|
|
Karsten Hopp |
bbb847 |
*** ../vim-7.4.008/src/fileio.c 2013-08-05 21:58:03.000000000 +0200
|
|
Karsten Hopp |
bbb847 |
--- src/fileio.c 2013-08-25 17:45:27.000000000 +0200
|
|
Karsten Hopp |
bbb847 |
***************
|
|
Karsten Hopp |
bbb847 |
*** 2926,2934 ****
|
|
Karsten Hopp |
bbb847 |
--- 2926,2939 ----
|
|
Karsten Hopp |
bbb847 |
int *did_ask; /* flag: whether already asked for key */
|
|
Karsten Hopp |
bbb847 |
{
|
|
Karsten Hopp |
bbb847 |
int method = crypt_method_from_magic((char *)ptr, *sizep);
|
|
Karsten Hopp |
bbb847 |
+ int b_p_ro = curbuf->b_p_ro;
|
|
Karsten Hopp |
bbb847 |
|
|
Karsten Hopp |
bbb847 |
if (method >= 0)
|
|
Karsten Hopp |
bbb847 |
{
|
|
Karsten Hopp |
bbb847 |
+ /* Mark the buffer as read-only until the decryption has taken place.
|
|
Karsten Hopp |
bbb847 |
+ * Avoids accidentally overwriting the file with garbage. */
|
|
Karsten Hopp |
bbb847 |
+ curbuf->b_p_ro = TRUE;
|
|
Karsten Hopp |
bbb847 |
+
|
|
Karsten Hopp |
bbb847 |
set_crypt_method(curbuf, method);
|
|
Karsten Hopp |
bbb847 |
if (method > 0)
|
|
Karsten Hopp |
bbb847 |
(void)blowfish_self_test();
|
|
Karsten Hopp |
bbb847 |
***************
|
|
Karsten Hopp |
bbb847 |
*** 2977,2982 ****
|
|
Karsten Hopp |
bbb847 |
--- 2982,2989 ----
|
|
Karsten Hopp |
bbb847 |
*sizep -= CRYPT_MAGIC_LEN + salt_len + seed_len;
|
|
Karsten Hopp |
bbb847 |
mch_memmove(ptr, ptr + CRYPT_MAGIC_LEN + salt_len + seed_len,
|
|
Karsten Hopp |
bbb847 |
(size_t)*sizep);
|
|
Karsten Hopp |
bbb847 |
+ /* Restore the read-only flag. */
|
|
Karsten Hopp |
bbb847 |
+ curbuf->b_p_ro = b_p_ro;
|
|
Karsten Hopp |
bbb847 |
}
|
|
Karsten Hopp |
bbb847 |
}
|
|
Karsten Hopp |
bbb847 |
/* When starting to edit a new file which does not have encryption, clear
|
|
Karsten Hopp |
bbb847 |
*** ../vim-7.4.008/src/version.c 2013-08-25 17:01:36.000000000 +0200
|
|
Karsten Hopp |
bbb847 |
--- src/version.c 2013-08-25 17:44:30.000000000 +0200
|
|
Karsten Hopp |
bbb847 |
***************
|
|
Karsten Hopp |
bbb847 |
*** 729,730 ****
|
|
Karsten Hopp |
bbb847 |
--- 729,732 ----
|
|
Karsten Hopp |
bbb847 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
bbb847 |
+ /**/
|
|
Karsten Hopp |
bbb847 |
+ 9,
|
|
Karsten Hopp |
bbb847 |
/**/
|
|
Karsten Hopp |
bbb847 |
|
|
Karsten Hopp |
bbb847 |
--
|
|
Karsten Hopp |
bbb847 |
I have a watch cat! Just break in and she'll watch.
|
|
Karsten Hopp |
bbb847 |
|
|
Karsten Hopp |
bbb847 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
bbb847 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
bbb847 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
bbb847 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|