From: Nikos Mavrogiannopoulos Date: Fri, 9 Nov 2018 19:11:42 +0000 (+0100) Subject: Added checks to avoid false negatives reported by static analyzers X-Git-Tag: gnutls_3_6_5~31^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f3da49beff97b399325f4616b6096d7bbdec268d;p=thirdparty%2Fgnutls.git Added checks to avoid false negatives reported by static analyzers Signed-off-by: Nikos Mavrogiannopoulos --- diff --git a/lib/x509/dn.c b/lib/x509/dn.c index 07b9d94b6b..828bd9059d 100644 --- a/lib/x509/dn.c +++ b/lib/x509/dn.c @@ -286,6 +286,8 @@ _gnutls_x509_parse_dn(ASN1_TYPE asn1_struct, goto cleanup; } + assert(dn.data != NULL); + if (buf) { memcpy(buf, dn.data, dn.size); buf[dn.size] = 0; diff --git a/lib/x509/x509.c b/lib/x509/x509.c index 1880f6acc3..6fe6cd91c3 100644 --- a/lib/x509/x509.c +++ b/lib/x509/x509.c @@ -154,6 +154,9 @@ gnutls_x509_crt_equals2(gnutls_x509_crt_t cert1, { bool result; + if (cert1 == NULL || der == NULL) + return 0; + if (cert1->der.size == 0 || cert1->modified) { gnutls_datum_t tmp1; int ret; @@ -4196,8 +4199,10 @@ void gnutls_x509_crt_set_pin_function(gnutls_x509_crt_t crt, gnutls_pin_callback_t fn, void *userdata) { - crt->pin.cb = fn; - crt->pin.data = userdata; + if (crt) { + crt->pin.cb = fn; + crt->pin.data = userdata; + } } /**