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

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