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

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