Blame SOURCES/0001-coverity-add-missing-NULL-checks.patch

69a8fd
From 3c652910d05616ee12c710e2071fc884dde4eaea Mon Sep 17 00:00:00 2001
69a8fd
From: Sumit Bose <sbose@redhat.com>
69a8fd
Date: Wed, 2 Jun 2021 13:39:31 +0200
69a8fd
Subject: [PATCH 1/2] coverity: add missing NULL checks
69a8fd
69a8fd
---
69a8fd
 library/adenroll.c | 2 ++
69a8fd
 library/adldap.c   | 7 +++++++
69a8fd
 2 files changed, 9 insertions(+)
69a8fd
69a8fd
diff --git a/library/adenroll.c b/library/adenroll.c
69a8fd
index 2b830a4..0f3e8b9 100644
69a8fd
--- a/library/adenroll.c
69a8fd
+++ b/library/adenroll.c
69a8fd
@@ -3060,6 +3060,8 @@ adcli_enroll_set_keytab_enctypes (adcli_enroll *enroll,
69a8fd
 	krb5_enctype *newval = NULL;
69a8fd
 	int len;
69a8fd
 
69a8fd
+	return_if_fail (enroll != NULL);
69a8fd
+
69a8fd
 	if (value) {
69a8fd
 		for (len = 0; value[len] != 0; len++);
69a8fd
 		newval = malloc (sizeof (krb5_enctype) * (len + 1));
69a8fd
diff --git a/library/adldap.c b/library/adldap.c
69a8fd
index d93efb7..b86014c 100644
69a8fd
--- a/library/adldap.c
69a8fd
+++ b/library/adldap.c
69a8fd
@@ -231,6 +231,13 @@ _adcli_ldap_have_in_mod (LDAPMod *mod,
69a8fd
 
69a8fd
 	vals = malloc (sizeof (struct berval) * (count + 1));
69a8fd
 	pvals = malloc (sizeof (struct berval *) * (count + 1));
69a8fd
+	if (vals == NULL || pvals == NULL) {
69a8fd
+		_adcli_err ("Memory allocation failed, assuming attribute must be updated.");
69a8fd
+		free (vals);
69a8fd
+		free (pvals);
69a8fd
+		return 0;
69a8fd
+	}
69a8fd
+
69a8fd
 	for (i = 0; i < count; i++) {
69a8fd
 		vals[i].bv_val = mod->mod_vals.modv_strvals[i];
69a8fd
 		vals[i].bv_len = strlen (vals[i].bv_val);
69a8fd
-- 
69a8fd
2.31.1
69a8fd