diff src/crypt.c @ 15531:959cf4c63b18 v8.1.0773

patch 8.1.0773: not all crypt code is tested commit https://github.com/vim/vim/commit/987411db9e4b76b524d0579db21074be0bffd61b Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 18 22:48:34 2019 +0100 patch 8.1.0773: not all crypt code is tested Problem: Not all crypt code is tested. Solution: Disable unused crypt code. Add more test coverage.
author Bram Moolenaar <Bram@vim.org>
date Fri, 18 Jan 2019 23:00:08 +0100
parents 55ccc2d353bd
children dd725a8ab112
line wrap: on
line diff
--- a/src/crypt.c
+++ b/src/crypt.c
@@ -34,7 +34,9 @@ typedef struct {
     char    *magic;	/* magic bytes stored in file header */
     int	    salt_len;	/* length of salt, or 0 when not using salt */
     int	    seed_len;	/* length of seed, or 0 when not using salt */
+#ifdef CRYPT_NOT_INPLACE
     int	    works_inplace; /* encryption/decryption can be done in-place */
+#endif
     int	    whole_undofile; /* whole undo file is encrypted */
 
     /* Optional function pointer for a self-test. */
@@ -80,7 +82,9 @@ static cryptmethod_T cryptmethods[CRYPT_
 	"VimCrypt~01!",
 	0,
 	0,
+#ifdef CRYPT_NOT_INPLACE
 	TRUE,
+#endif
 	FALSE,
 	NULL,
 	crypt_zip_init,
@@ -95,7 +99,9 @@ static cryptmethod_T cryptmethods[CRYPT_
 	"VimCrypt~02!",
 	8,
 	8,
+#ifdef CRYPT_NOT_INPLACE
 	TRUE,
+#endif
 	FALSE,
 	blowfish_self_test,
 	crypt_blowfish_init,
@@ -110,7 +116,9 @@ static cryptmethod_T cryptmethods[CRYPT_
 	"VimCrypt~03!",
 	8,
 	8,
+#ifdef CRYPT_NOT_INPLACE
 	TRUE,
+#endif
 	TRUE,
 	blowfish_self_test,
 	crypt_blowfish_init,
@@ -167,6 +175,7 @@ crypt_method_nr_from_magic(char *ptr, in
     return -1;
 }
 
+#ifdef CRYPT_NOT_INPLACE
 /*
  * Return TRUE if the crypt method for "method_nr" can be done in-place.
  */
@@ -175,6 +184,7 @@ crypt_works_inplace(cryptstate_T *state)
 {
     return cryptmethods[state->method_nr].works_inplace;
 }
+#endif
 
 /*
  * Get the crypt method for buffer "buf" as a number.
@@ -366,6 +376,7 @@ crypt_free_state(cryptstate_T *state)
     vim_free(state);
 }
 
+#ifdef CRYPT_NOT_INPLACE
 /*
  * Encode "from[len]" and store the result in a newly allocated buffer, which
  * is stored in "newptr".
@@ -422,6 +433,7 @@ crypt_decode_alloc(
     method->decode_fn(state, ptr, len, *newptr);
     return len;
 }
+#endif
 
 /*
  * Encrypting "from[len]" into "to[len]".
@@ -436,6 +448,7 @@ crypt_encode(
     cryptmethods[state->method_nr].encode_fn(state, from, len, to);
 }
 
+#if 0  // unused
 /*
  * decrypting "from[len]" into "to[len]".
  */
@@ -448,6 +461,7 @@ crypt_decode(
 {
     cryptmethods[state->method_nr].decode_fn(state, from, len, to);
 }
+#endif
 
 /*
  * Simple inplace encryption, modifies "buf[len]" in place.