diff options
author | Werner Koch <wk@gnupg.org> | 2016-06-25 15:38:06 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2016-06-25 15:38:49 +0200 |
commit | 5a5b055b81ee60a22a846bdf2031516b1c24df98 (patch) | |
tree | 39dff2932cf6d52325e87e1e278457ac4a6ba5a1 /cipher/cipher.c | |
parent | 3f98b1e92d5afd720d7cea5b4e8295c5018bf9ac (diff) | |
download | libgcrypt-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 'cipher/cipher.c')
-rw-r--r-- | cipher/cipher.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/cipher/cipher.c b/cipher/cipher.c index bdcbfbd7..2b7bf210 100644 --- a/cipher/cipher.c +++ b/cipher/cipher.c @@ -175,8 +175,10 @@ search_oid (const char *oid, gcry_cipher_oid_spec_t *oid_spec) gcry_cipher_spec_t *spec; int i; - if (oid && ((! strncmp (oid, "oid.", 4)) - || (! strncmp (oid, "OID.", 4)))) + if (!oid) + return NULL; + + if (!strncmp (oid, "oid.", 4) || !strncmp (oid, "OID.", 4)) oid += 4; spec = spec_from_oid (oid); |