From 987411db9e4b76b524d0579db21074be0bffd61b Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 18 Jan 2019 22:48:34 +0100 Subject: 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. --- src/crypt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/crypt.c') diff --git a/src/crypt.c b/src/crypt.c index 599607078a..f82ee7bdb7 100644 --- 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_M_COUNT] = { "VimCrypt~01!", 0, 0, +#ifdef CRYPT_NOT_INPLACE TRUE, +#endif FALSE, NULL, crypt_zip_init, @@ -95,7 +99,9 @@ static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = { "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_M_COUNT] = { "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, int len) 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. -- cgit v1.2.3