andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
Blob Blame History Raw
From b8fa0a00375db306292691b8c1f3a4a897ce57bd Mon Sep 17 00:00:00 2001
From: Mark Reynolds <mreynolds@redhat.com>
Date: Thu, 13 Mar 2014 15:43:28 -0400
Subject: [PATCH 187/225] Ticket 47740 - Fix coverity issues: null deferences -
 Part 6

12474 - Null pointer dereference - ldap/servers/slapd/tools/migratecred.c
12473 - Null pointer dereference - ldap/srevers/slapd/snmp/main.c
12468 - Null pointer dereference - ldap/servers/plugins/memberof/memberof.c

https://fedorahosted.org/389/ticket/47740

Reviewed by: rmeggins(Thanks!)
(cherry picked from commit d39807865d63244236ef2dcbd36d74ae857419a3)
(cherry picked from commit 0d6db17d8c9a23a9792eb76d49257845baa24b2c)
---
 ldap/servers/plugins/memberof/memberof.c | 2 +-
 ldap/servers/slapd/tools/migratecred.c   | 2 +-
 ldap/servers/snmp/main.c                 | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index d11983b..49e0d7a 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -977,7 +977,7 @@ int memberof_postop_add(Slapi_PBlock *pb)
 
 			memberof_lock();
 
-			for (i = 0; configCopy.groupattrs[i]; i++)
+			for (i = 0; configCopy.groupattrs && configCopy.groupattrs[i]; i++)
 			{
 				if(0 == slapi_entry_attr_find(e, configCopy.groupattrs[i], &attr))
 				{
diff --git a/ldap/servers/slapd/tools/migratecred.c b/ldap/servers/slapd/tools/migratecred.c
index 83f2667..085a21a 100644
--- a/ldap/servers/slapd/tools/migratecred.c
+++ b/ldap/servers/slapd/tools/migratecred.c
@@ -137,7 +137,7 @@ main( int argc, char **argv)
 					/* cred has the prefix, remove it before decoding */
 					prefixCred = strdup(optarg);
 					
-					if ((*prefixCred == PWD_HASH_PREFIX_START) &&
+					if (prefixCred && (*prefixCred == PWD_HASH_PREFIX_START) &&
 						((end = strchr(prefixCred, PWD_HASH_PREFIX_END)) != NULL) &&
 						((namelen = end - prefixCred - 1 ) <= (3*PWD_MAX_NAME_LEN)) )
 					{
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index 78d4814..d6b0427 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -445,8 +445,8 @@ load_config(char *conf_path)
                             got_port = 1;
                         } else if (strcmp(attr, "nsslapd-rundir") == 0) {
                             /* 8 =  "/" + ".stats" + \0 */
-                            serv_p->stats_file = malloc(vlen + strlen(instancename) + 8);
-                            if (serv_p->stats_file != NULL) {
+                            serv_p->stats_file = malloc(vlen + (instancename ? strlen(instancename) : 0) + 8);
+                            if (serv_p->stats_file && instancename) {
                                 snprintf(serv_p->stats_file, vlen + strlen(instancename) + 8,
                                          "%s/%s.stats", val, instancename);
                                 serv_p->stats_file[(vlen + strlen(instancename) + 7)] = (char)0;
-- 
1.8.1.4