mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
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.
This commit is contained in:
14
src/crypt.c
14
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.
|
||||
|
Reference in New Issue
Block a user