summaryrefslogtreecommitdiff
path: root/mpi
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2016-06-25 15:38:06 +0200
committerWerner Koch <wk@gnupg.org>2016-06-25 15:38:49 +0200
commit5a5b055b81ee60a22a846bdf2031516b1c24df98 (patch)
tree39dff2932cf6d52325e87e1e278457ac4a6ba5a1 /mpi
parent3f98b1e92d5afd720d7cea5b4e8295c5018bf9ac (diff)
downloadlibgcrypt-5a5b055b81ee60a22a846bdf2031516b1c24df98.tar.gz
Improve robustness and help lint.
* cipher/rsa.c (rsa_encrypt): Check for !DATA. * cipher/md.c (search_oid): Check early for !OID. (md_copy): Use gpg_err_code_from_syserror. Replace chains of if(!err) tests. * cipher/cipher.c (search_oid): Check early for !OID. * src/misc.c (do_printhex): Allow for BUFFER==NULL even with LENGTH>0. * mpi/mpicoder.c (onecompl): Allow for A==NULL to help static analyzers. -- The change for md_copy is to help static analyzers which have no idea that gpg_err_code_from_syserror will never return 0. A gcc attribute returns_nonzero would be a nice to have. Some changes are due to the fact the macros like mpi_is_immutable gracefully handle a NULL arg but a static analyzer the considers that the function allows for a NULL arg. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'mpi')
-rw-r--r--mpi/mpicoder.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/mpi/mpicoder.c b/mpi/mpicoder.c
index e3155766..4c63a147 100644
--- a/mpi/mpicoder.c
+++ b/mpi/mpicoder.c
@@ -403,14 +403,16 @@ onecompl (gcry_mpi_t a)
mpi_ptr_t ap;
mpi_size_t n;
unsigned int i;
- unsigned int nbits = mpi_get_nbits (a);
+ unsigned int nbits;
- if (mpi_is_immutable (a))
+ if (!a || mpi_is_immutable (a))
{
mpi_immutable_failed ();
return;
}
+ nbits = mpi_get_nbits (a);
+
mpi_normalize (a);
ap = a->d;
n = a->nlimbs;