Browse Source

Ticket 49269 - Fix coverity errors

Desciption:  Fix coverity and clanf errors/warnings.  Also fix a compiler warning

https://pagure.io/389-ds-base/issue/49269

Reviewed by: firstyear(Thanks!)
Mark Reynolds 8 years ago
parent
commit
c2c512e4fa

+ 8 - 1
ldap/servers/plugins/http/http_impl.c

@@ -591,15 +591,22 @@ static PRStatus sendPostReq(PRFileDesc *fd, const char *path, httpheader **httph
 	PRInt32 http_connection_time_out = 0;
 	int i = 0;
 	int body_len, buflen = 0; 
+	int path_len;
 
 	if (body) {
 		body_len = strlen(body);
 	} else {
 		body_len = 0;
 	}
+	if (path) {
+		path_len = strlen(path);
+	} else {
+		path_len = 0;
+	}
+
 	PR_snprintf(body_len_str, sizeof(body_len_str), "%d", body_len);
 
-	buflen = (HTTP_POST_STD_LEN + strlen(path) + body_len + strlen(body_len_str));
+	buflen = (HTTP_POST_STD_LEN + path_len + body_len + strlen(body_len_str));
 
 	for (i = 0; httpheaderArray[i] != NULL; i++) {
 

+ 3 - 0
ldap/servers/plugins/pwdstorage/crypt_pwd.c

@@ -108,6 +108,9 @@ crypt_pw_enc_by_hash( const char *pwd, int hash_algo){
         algo_salt = slapi_ch_smprintf("$5$%s", salt);
     } else if (hash_algo == CRYPT_SHA512) {
         algo_salt = slapi_ch_smprintf("$6$%s", salt);
+    } else {
+        /* default to CRYPT_UNIX */
+        algo_salt = strdup(salt);
     }
 
     PR_Lock(cryptlock);

+ 3 - 2
ldap/servers/plugins/replication/repl_extop.c

@@ -1158,7 +1158,8 @@ send_response:
 				
 				r_locking_conn = replica_get_locking_conn(r);
 				slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "multimaster_extop_StartNSDS50ReplicationRequest - "
-				"already acquired replica: locking_conn=%d, current connid=%d\n", (int) r_locking_conn, (int) connid);
+					"already acquired replica: locking_conn=%" PRIu64 ", current connid=%" PRIu64 "\n",
+					r_locking_conn, connid);
 				
 				if ((r_locking_conn != ULONG_MAX) && (r_locking_conn == connid)) {
 					replica_relinquish_exclusive_access(r, connid, opid);
@@ -1174,7 +1175,7 @@ send_response:
 			 * that the RA will restart a new session in a clear state 
 			 */
 			slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "multimaster_extop_StartNSDS50ReplicationRequest - "
-				"already acquired replica: disconnect conn=%d\n", connid);
+				"already acquired replica: disconnect conn=%" PRIu64 "\n", connid);
 			slapi_disconnect_server(conn);
             
 		}

+ 1 - 1
ldap/servers/slapd/pw_verify.c

@@ -118,7 +118,7 @@ pw_validate_be_dn(Slapi_PBlock *pb, Slapi_Entry **referral)
     }
 
     /* We need a slapi_sdn_isanon? */
-    if (method == LDAP_AUTH_SIMPLE && cred->bv_len == 0) {
+    if (method == LDAP_AUTH_SIMPLE && (cred == NULL || cred->bv_len == 0)) {
         return SLAPI_BIND_ANONYMOUS;
     }
 

+ 1 - 1
lib/libaccess/oneeval.cpp

@@ -658,7 +658,7 @@ ACL_INTEvalTestRights(
      *     place to do it.
      */
 
-    while (*rights)
+    while (*rights && rights_cnt < ACL_MAX_TEST_RIGHTS)
     {
         rarray_p = &rights_arry[rights_cnt];