comparison src/crypt.c @ 24986:fa31a0ea09e1 v8.2.3030

patch 8.2.3030: Coverity reports a memory leak Commit: https://github.com/vim/vim/commit/cb54bc65625abad9a0af501acac5c70fba17e2cc Author: Dominique Pelle <dominique.pelle@gmail.com> Date: Mon Jun 21 20:15:37 2021 +0200 patch 8.2.3030: Coverity reports a memory leak Problem: Coverity reports a memory leak. Solution: Fix the leak and a few typos. (Dominique Pell?, closes https://github.com/vim/vim/issues/8418)
author Bram Moolenaar <Bram@vim.org>
date Mon, 21 Jun 2021 20:30:04 +0200
parents 7e9e53a0368f
children 85d1e82ed134
comparison
equal deleted inserted replaced
24985:a6816d5be1ac 24986:fa31a0ea09e1
817 } 817 }
818 818
819 if (sod_st->count && len <= crypto_secretstream_xchacha20poly1305_ABYTES) 819 if (sod_st->count && len <= crypto_secretstream_xchacha20poly1305_ABYTES)
820 { 820 {
821 emsg(e_libsodium_cannot_decrypt_buffer); 821 emsg(e_libsodium_cannot_decrypt_buffer);
822 return; 822 goto fail;
823 } 823 }
824 if (crypto_secretstream_xchacha20poly1305_pull(&sod_st->state, 824 if (crypto_secretstream_xchacha20poly1305_pull(&sod_st->state,
825 buf_out, &buf_len, &tag, from, len, NULL, 0) != 0) 825 buf_out, &buf_len, &tag, from, len, NULL, 0) != 0)
826 { 826 {
827 emsg(e_libsodium_decription_failed); 827 emsg(e_libsodium_decryption_failed);
828 goto fail; 828 goto fail;
829 } 829 }
830 sod_st->count++; 830 sod_st->count++;
831 831
832 if (tag == crypto_secretstream_xchacha20poly1305_TAG_FINAL && !last) 832 if (tag == crypto_secretstream_xchacha20poly1305_TAG_FINAL && !last)
833 { 833 {
834 emsg(e_libsodium_decyption_failed_premature); 834 emsg(e_libsodium_decryption_failed_premature);
835 goto fail; 835 goto fail;
836 } 836 }
837 if (p1 == p2) 837 if (p1 == p2)
838 mch_memmove(p2, buf_out, buf_len); 838 mch_memmove(p2, buf_out, buf_len);
839 839
929 sod_st->count++; 929 sod_st->count++;
930 } 930 }
931 if (crypto_secretstream_xchacha20poly1305_pull(&sod_st->state, 931 if (crypto_secretstream_xchacha20poly1305_pull(&sod_st->state,
932 *buf_out, &out_len, &tag, from, len, NULL, 0) != 0) 932 *buf_out, &out_len, &tag, from, len, NULL, 0) != 0)
933 { 933 {
934 emsg(e_libsodium_decription_failed); 934 emsg(e_libsodium_decryption_failed);
935 return -1; 935 return -1;
936 } 936 }
937 937
938 if (tag == crypto_secretstream_xchacha20poly1305_TAG_FINAL && !last) 938 if (tag == crypto_secretstream_xchacha20poly1305_TAG_FINAL && !last)
939 emsg(e_libsodium_decyption_failed_premature); 939 emsg(e_libsodium_decryption_failed_premature);
940 return (long) out_len; 940 return (long) out_len;
941 # else 941 # else
942 return -1; 942 return -1;
943 # endif 943 # endif
944 } 944 }