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

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