andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From b8fa0a00375db306292691b8c1f3a4a897ce57bd Mon Sep 17 00:00:00 2001
dc8c34
From: Mark Reynolds <mreynolds@redhat.com>
dc8c34
Date: Thu, 13 Mar 2014 15:43:28 -0400
dc8c34
Subject: [PATCH 187/225] Ticket 47740 - Fix coverity issues: null deferences -
dc8c34
 Part 6
dc8c34
dc8c34
12474 - Null pointer dereference - ldap/servers/slapd/tools/migratecred.c
dc8c34
12473 - Null pointer dereference - ldap/srevers/slapd/snmp/main.c
dc8c34
12468 - Null pointer dereference - ldap/servers/plugins/memberof/memberof.c
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/47740
dc8c34
dc8c34
Reviewed by: rmeggins(Thanks!)
dc8c34
(cherry picked from commit d39807865d63244236ef2dcbd36d74ae857419a3)
dc8c34
(cherry picked from commit 0d6db17d8c9a23a9792eb76d49257845baa24b2c)
dc8c34
---
dc8c34
 ldap/servers/plugins/memberof/memberof.c | 2 +-
dc8c34
 ldap/servers/slapd/tools/migratecred.c   | 2 +-
dc8c34
 ldap/servers/snmp/main.c                 | 4 ++--
dc8c34
 3 files changed, 4 insertions(+), 4 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
dc8c34
index d11983b..49e0d7a 100644
dc8c34
--- a/ldap/servers/plugins/memberof/memberof.c
dc8c34
+++ b/ldap/servers/plugins/memberof/memberof.c
dc8c34
@@ -977,7 +977,7 @@ int memberof_postop_add(Slapi_PBlock *pb)
dc8c34
 
dc8c34
 			memberof_lock();
dc8c34
 
dc8c34
-			for (i = 0; configCopy.groupattrs[i]; i++)
dc8c34
+			for (i = 0; configCopy.groupattrs && configCopy.groupattrs[i]; i++)
dc8c34
 			{
dc8c34
 				if(0 == slapi_entry_attr_find(e, configCopy.groupattrs[i], &attr))
dc8c34
 				{
dc8c34
diff --git a/ldap/servers/slapd/tools/migratecred.c b/ldap/servers/slapd/tools/migratecred.c
dc8c34
index 83f2667..085a21a 100644
dc8c34
--- a/ldap/servers/slapd/tools/migratecred.c
dc8c34
+++ b/ldap/servers/slapd/tools/migratecred.c
dc8c34
@@ -137,7 +137,7 @@ main( int argc, char **argv)
dc8c34
 					/* cred has the prefix, remove it before decoding */
dc8c34
 					prefixCred = strdup(optarg);
dc8c34
 					
dc8c34
-					if ((*prefixCred == PWD_HASH_PREFIX_START) &&
dc8c34
+					if (prefixCred && (*prefixCred == PWD_HASH_PREFIX_START) &&
dc8c34
 						((end = strchr(prefixCred, PWD_HASH_PREFIX_END)) != NULL) &&
dc8c34
 						((namelen = end - prefixCred - 1 ) <= (3*PWD_MAX_NAME_LEN)) )
dc8c34
 					{
dc8c34
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
dc8c34
index 78d4814..d6b0427 100644
dc8c34
--- a/ldap/servers/snmp/main.c
dc8c34
+++ b/ldap/servers/snmp/main.c
dc8c34
@@ -445,8 +445,8 @@ load_config(char *conf_path)
dc8c34
                             got_port = 1;
dc8c34
                         } else if (strcmp(attr, "nsslapd-rundir") == 0) {
dc8c34
                             /* 8 =  "/" + ".stats" + \0 */
dc8c34
-                            serv_p->stats_file = malloc(vlen + strlen(instancename) + 8);
dc8c34
-                            if (serv_p->stats_file != NULL) {
dc8c34
+                            serv_p->stats_file = malloc(vlen + (instancename ? strlen(instancename) : 0) + 8);
dc8c34
+                            if (serv_p->stats_file && instancename) {
dc8c34
                                 snprintf(serv_p->stats_file, vlen + strlen(instancename) + 8,
dc8c34
                                          "%s/%s.stats", val, instancename);
dc8c34
                                 serv_p->stats_file[(vlen + strlen(instancename) + 7)] = (char)0;
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34