Mercurial > vim
comparison src/blowfish.c @ 16429:a1229400434a v8.1.1219
patch 8.1.1219: not checking for NULL return from alloc()
commit https://github.com/vim/vim/commit/6ee9658774942f7448af700fc04df0335796a3db
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 27 22:06:37 2019 +0200
patch 8.1.1219: not checking for NULL return from alloc()
Problem: Not checking for NULL return from alloc().
Solution: Add checks. (Martin Kunev, closes https://github.com/vim/vim/issues/4303, closes https://github.com/vim/vim/issues/4174)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 27 Apr 2019 22:15:05 +0200 |
parents | 7fad90423bd2 |
children | ce04ebdf26b8 |
comparison
equal
deleted
inserted
replaced
16428:6f69ef2913d7 | 16429:a1229400434a |
---|---|
634 to[i] = from[i] ^ t; | 634 to[i] = from[i] ^ t; |
635 BF_CFB_UPDATE(bfs, to[i]); | 635 BF_CFB_UPDATE(bfs, to[i]); |
636 } | 636 } |
637 } | 637 } |
638 | 638 |
639 void | 639 int |
640 crypt_blowfish_init( | 640 crypt_blowfish_init( |
641 cryptstate_T *state, | 641 cryptstate_T *state, |
642 char_u* key, | 642 char_u* key, |
643 char_u* salt, | 643 char_u* salt, |
644 int salt_len, | 644 int salt_len, |
645 char_u* seed, | 645 char_u* seed, |
646 int seed_len) | 646 int seed_len) |
647 { | 647 { |
648 bf_state_T *bfs = (bf_state_T *)alloc_clear(sizeof(bf_state_T)); | 648 bf_state_T *bfs = (bf_state_T *)alloc_clear(sizeof(bf_state_T)); |
649 | 649 |
650 if (bfs == NULL) | |
651 return FAIL; | |
650 state->method_state = bfs; | 652 state->method_state = bfs; |
651 | 653 |
652 /* "blowfish" uses a 64 byte buffer, causing it to repeat 8 byte groups 8 | 654 /* "blowfish" uses a 64 byte buffer, causing it to repeat 8 byte groups 8 |
653 * times. "blowfish2" uses a 8 byte buffer to avoid repeating. */ | 655 * times. "blowfish2" uses a 8 byte buffer to avoid repeating. */ |
654 bfs->cfb_len = state->method_nr == CRYPT_M_BF ? BF_MAX_CFB_LEN : BF_BLOCK; | 656 bfs->cfb_len = state->method_nr == CRYPT_M_BF ? BF_MAX_CFB_LEN : BF_BLOCK; |
655 | 657 |
656 if (blowfish_self_test() == FAIL) | 658 if (blowfish_self_test() == FAIL) |
657 return; | 659 return FAIL; |
658 | 660 |
659 bf_key_init(bfs, key, salt, salt_len); | 661 bf_key_init(bfs, key, salt, salt_len); |
660 bf_cfb_init(bfs, seed, seed_len); | 662 bf_cfb_init(bfs, seed, seed_len); |
663 | |
664 return OK; | |
661 } | 665 } |
662 | 666 |
663 /* | 667 /* |
664 * Run a test to check if the encryption works as expected. | 668 * Run a test to check if the encryption works as expected. |
665 * Give an error and return FAIL when not. | 669 * Give an error and return FAIL when not. |