d4e26e
From 8b236bc2c22ba907a9d8007889b7017122c26c2c Mon Sep 17 00:00:00 2001
d4e26e
From: tbordaz <tbordaz@redhat.com>
d4e26e
Date: Thu, 6 May 2021 18:50:06 +0200
d4e26e
Subject: [PATCH 1/2] Issue 4759 - Fix coverity issue (#4760)
d4e26e
d4e26e
Bug description:
d4e26e
	with #4218 (wtime, optime in access log), hrtime is set in the
d4e26e
	operation. But it is done before checking if the operation is
d4e26e
	set. covscan fails
d4e26e
d4e26e
Fix description:
d4e26e
	move the setting after verification that operation != NULL
d4e26e
d4e26e
relates: https://github.com/389ds/389-ds-base/issues/4759
d4e26e
d4e26e
Reviewed by: Simon Pichugin
d4e26e
d4e26e
Platforms tested: F34
d4e26e
---
d4e26e
 ldap/servers/slapd/extendop.c | 6 +++---
d4e26e
 ldap/servers/slapd/opshared.c | 6 +++---
d4e26e
 2 files changed, 6 insertions(+), 6 deletions(-)
d4e26e
d4e26e
diff --git a/ldap/servers/slapd/extendop.c b/ldap/servers/slapd/extendop.c
d4e26e
index 59a993ea8..fbd41c6ee 100644
d4e26e
--- a/ldap/servers/slapd/extendop.c
d4e26e
+++ b/ldap/servers/slapd/extendop.c
d4e26e
@@ -221,9 +221,6 @@ do_extended(Slapi_PBlock *pb)
d4e26e
     slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
d4e26e
     slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
d4e26e
 
d4e26e
-    /* Set the time we actually started the operation */
d4e26e
-    slapi_operation_set_time_started(pb_op);
d4e26e
-
d4e26e
     if (pb_conn == NULL || pb_op == NULL) {
d4e26e
         send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, "param error", 0, NULL);
d4e26e
         slapi_log_err(SLAPI_LOG_ERR, "do_extended",
d4e26e
@@ -231,6 +228,9 @@ do_extended(Slapi_PBlock *pb)
d4e26e
         goto free_and_return;
d4e26e
     }
d4e26e
 
d4e26e
+    /* Set the time we actually started the operation */
d4e26e
+    slapi_operation_set_time_started(pb_op);
d4e26e
+
d4e26e
     /*
d4e26e
      * Parse the extended request. It looks like this:
d4e26e
      *
d4e26e
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
d4e26e
index 2afb8e2fc..05b9a1553 100644
d4e26e
--- a/ldap/servers/slapd/opshared.c
d4e26e
+++ b/ldap/servers/slapd/opshared.c
d4e26e
@@ -276,9 +276,6 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
d4e26e
     slapi_pblock_get(pb, SLAPI_SEARCH_TARGET_SDN, &sdn;;
d4e26e
     slapi_pblock_get(pb, SLAPI_OPERATION, &operation);
d4e26e
 
d4e26e
-    /* Set the time we actually started the operation */
d4e26e
-    slapi_operation_set_time_started(operation);
d4e26e
-
d4e26e
     if (NULL == sdn) {
d4e26e
         sdn = slapi_sdn_new_dn_byval(base);
d4e26e
         slapi_pblock_set(pb, SLAPI_SEARCH_TARGET_SDN, sdn);
d4e26e
@@ -309,6 +306,9 @@ op_shared_search(Slapi_PBlock *pb, int send_result)
d4e26e
         rc = -1;
d4e26e
         goto free_and_return_nolock;
d4e26e
     }
d4e26e
+    
d4e26e
+    /* Set the time we actually started the operation */
d4e26e
+    slapi_operation_set_time_started(operation);
d4e26e
 
d4e26e
     internal_op = operation_is_flag_set(operation, OP_FLAG_INTERNAL);
d4e26e
     flag_psearch = operation_is_flag_set(operation, OP_FLAG_PS);
d4e26e
-- 
d4e26e
2.30.2
d4e26e