Browse Source

Ticket 47368 - Fix coverity issues

CID 12376 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)
CID 12377 (#1 of 1): Uninitialized pointer read (UNINIT)

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

Reviewed by: rmeggins(Thanks!)
Mark Reynolds 12 years ago
parent
commit
8d398a555f

+ 3 - 3
ldap/servers/plugins/replication/repl5_agmt.c

@@ -2929,14 +2929,14 @@ done:
 /*
  * Parse out the consumer replicaID from the agmt maxcsn
  *
- *  "repl area;agmt rdn;hostname;port;consumer rid;maxcsn"
+ *  "repl area;agmt_rdn;hostname;port;consumer_rid;maxcsn"
  */
 static ReplicaId
 agmt_maxcsn_get_rid(char *maxcsn)
 {
     ReplicaId rid = 0;
     char *token = NULL;
-    char *iter;
+    char *iter = NULL;
     char *value = slapi_ch_strdup(maxcsn);
 
     token = ldap_utf8strtok_r(value, ";", &iter); /* repl area */
@@ -2945,7 +2945,7 @@ agmt_maxcsn_get_rid(char *maxcsn)
     token = ldap_utf8strtok_r(iter, ";", &iter);  /* port */
     token = ldap_utf8strtok_r(iter, ";", &iter);  /* rid */
 
-    if(strcmp(token, "Unavailable")){
+    if(token && strcmp(token, "Unavailable")){
         rid = atoi(token);
     }
     slapi_ch_free_string(&value);

+ 6 - 2
ldap/servers/plugins/replication/repl5_replica.c

@@ -3947,11 +3947,15 @@ replica_get_agmt_count(Replica *r)
 void
 replica_incr_agmt_count(Replica *r)
 {
-	r->agmt_count++;
+	if(r){
+		r->agmt_count++;
+	}
 }
 
 void
 replica_decr_agmt_count(Replica *r)
 {
-	r->agmt_count--;
+	if(r){
+		r->agmt_count--;
+	}
 }