summaryrefslogtreecommitdiff
path: root/src
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 /src
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 'src')
-rw-r--r--src/misc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/misc.c b/src/misc.c
index ac64d703..413d7d82 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -291,7 +291,7 @@ do_printhex (const char *text, const char *text2,
log_debug ("%*s ", (int)strlen(text), "");
}
}
- if (length)
+ if (length && buffer)
{
const unsigned char *p = buffer;
for (; length--; p++)