qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gmur...@apache.org
Subject [qpid-dispatch] branch master updated: DISPATCH-1292 - Fixes to coverity issues
Date Tue, 19 Mar 2019 16:36:14 GMT
This is an automated email from the ASF dual-hosted git repository.

gmurthy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git


The following commit(s) were added to refs/heads/master by this push:
     new bdafbbe  DISPATCH-1292 - Fixes to coverity issues
bdafbbe is described below

commit bdafbbe02f2762ec3c38bc254e59c3efa9b23c9e
Author: Ganesh Murthy <gmurthy@redhat.com>
AuthorDate: Tue Mar 19 12:35:59 2019 -0400

    DISPATCH-1292 - Fixes to coverity issues
---
 router/src/main.c                                   |  4 +++-
 src/router_core/core_events.c                       |  2 +-
 .../modules/edge_addr_tracking/edge_addr_tracking.c |  2 +-
 src/router_core/modules/edge_router/addr_proxy.c    |  3 ++-
 src/router_node.c                                   |  1 +
 src/server.c                                        |  1 +
 tests/compose_test.c                                |  7 ++++++-
 tests/message_test.c                                | 21 +++++++++++++++++----
 8 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/router/src/main.c b/router/src/main.c
index db0b279..aae176e 100644
--- a/router/src/main.c
+++ b/router/src/main.c
@@ -188,8 +188,9 @@ static void daemon_process(const char *config_path, const char *python_pkgdir,
b
                 size_t path_size = 256;
                 int getcwd_error = 0;
                 cur_path = (char *) calloc(path_size, sizeof(char));
+                errno = 0;
 
-                while ((cur_path = getcwd(cur_path, path_size)) == NULL) {
+                while (getcwd(cur_path, path_size) == NULL) {
                     free(cur_path);
                     if ( errno != ERANGE ) {
                         // If unable to get current directory
@@ -199,6 +200,7 @@ static void daemon_process(const char *config_path, const char *python_pkgdir,
b
                     // If current path does not fit, allocate more memory
                     path_size += 256;
                     cur_path = (char *) calloc(path_size, sizeof(char));
+                    errno = 0;
                 }
 
                 // Populating fully qualified config file name
diff --git a/src/router_core/core_events.c b/src/router_core/core_events.c
index a7216e5..34e7b5f 100644
--- a/src/router_core/core_events.c
+++ b/src/router_core/core_events.c
@@ -48,7 +48,7 @@ qdrc_event_subscription_t *qdrc_event_subscribe_CT(qdr_core_t          
  *core,
     sub->on_link_event = on_link_event;
     sub->on_addr_event = on_addr_event;
 
-    assert((events & !(_QDRC_EVENT_CONN_RANGE | _QDRC_EVENT_LINK_RANGE | _QDRC_EVENT_ADDR_RANGE))
== 0);
+    assert((events & ~(_QDRC_EVENT_CONN_RANGE | _QDRC_EVENT_LINK_RANGE | _QDRC_EVENT_ADDR_RANGE))
== 0);
     assert(!(events & _QDRC_EVENT_CONN_RANGE) || on_conn_event);
     assert(!(events & _QDRC_EVENT_LINK_RANGE) || on_link_event);
     assert(!(events & _QDRC_EVENT_ADDR_RANGE) || on_addr_event);
diff --git a/src/router_core/modules/edge_addr_tracking/edge_addr_tracking.c b/src/router_core/modules/edge_addr_tracking/edge_addr_tracking.c
index b568652..c76e3d3 100644
--- a/src/router_core/modules/edge_addr_tracking/edge_addr_tracking.c
+++ b/src/router_core/modules/edge_addr_tracking/edge_addr_tracking.c
@@ -338,7 +338,7 @@ static void on_link_event(void *context, qdrc_event_t event, qdr_link_t
*link)
                 assert(link->edge_context == 0);
                 link->edge_context = endpoint_state;
                 endpoint_state->ref_count++;
-                if (qdrc_can_send_address(addr, link->conn) && endpoint_state)
{
+                if (qdrc_can_send_address(addr, link->conn)) {
                     qdrc_send_message(mc->core, addr, endpoint_state->endpoint, true);
                 }
             }
diff --git a/src/router_core/modules/edge_router/addr_proxy.c b/src/router_core/modules/edge_router/addr_proxy.c
index ed593fd..5cc54a7 100644
--- a/src/router_core/modules/edge_router/addr_proxy.c
+++ b/src/router_core/modules/edge_router/addr_proxy.c
@@ -115,7 +115,8 @@ static void set_waypoint_capability(qdr_terminus_t *term, char phase_char,
qd_di
     char cap[16];
     char suffix[3];
 
-    strcpy(cap, QD_CAPABILITY_WAYPOINT_DEFAULT);
+    strncpy(cap, QD_CAPABILITY_WAYPOINT_DEFAULT, 12);
+    //strcpy(cap, QD_CAPABILITY_WAYPOINT_DEFAULT);
     suffix[0] = '.';
     suffix[1] = '0' + ordinal;
     suffix[2] = '\0';
diff --git a/src/router_node.c b/src/router_node.c
index e87adcd..2c6771f 100644
--- a/src/router_node.c
+++ b/src/router_node.c
@@ -564,6 +564,7 @@ static bool AMQP_rx_handler(void* context, qd_link_t *link)
                 pn_delivery_settle(pnd);
                 qd_message_free(msg);
                 qd_iterator_free(addr_iter);
+                qd_bitmask_free(link_exclusions);
                 return next_delivery;
             }
         }
diff --git a/src/server.c b/src/server.c
index bcd4a82..320adfe 100644
--- a/src/server.c
+++ b/src/server.c
@@ -916,6 +916,7 @@ static bool handle(qd_server_t *qd_server, pn_event_t *e, pn_connection_t
*pn_co
             /* Check for immediate tasks */
             qd_immediate_visit();
         }
+        break;
 
     case PN_PROACTOR_TIMEOUT:
         qd_timer_visit();
diff --git a/tests/compose_test.c b/tests/compose_test.c
index 49f06b5..eec77be 100644
--- a/tests/compose_test.c
+++ b/tests/compose_test.c
@@ -356,7 +356,12 @@ static char *test_compose_subfields(void *context)
     qd_composed_field_t *field = qd_compose(QD_PERFORMATIVE_MESSAGE_ANNOTATIONS, 0);
     qd_compose_start_map(field);
     qd_compose_insert_buffers(field, &sub1->buffers);
-    if (!DEQ_IS_EMPTY(sub1->buffers)) return "Buffer chain ownership not transferred!";
+    if (!DEQ_IS_EMPTY(sub1->buffers)) {
+        qd_compose_free(sub1);
+        qd_compose_free(sub2);
+        qd_compose_free(sub3);
+        return "Buffer chain ownership not transferred!";
+    }
     qd_compose_free(sub1);
     qd_compose_insert_buffers(field, &sub2->buffers);
     qd_compose_free(sub2);
diff --git a/tests/message_test.c b/tests/message_test.c
index 141e6c1..3c12bc8 100644
--- a/tests/message_test.c
+++ b/tests/message_test.c
@@ -83,10 +83,17 @@ static char* test_send_to_messenger(void *context)
     pn_message_t *pn_msg = pn_message();
     size_t len = flatten_bufs(content);
     int result = pn_message_decode(pn_msg, buffer, len);
-    if (result != 0) return "Error in pn_message_decode";
+    if (result != 0) {
+        pn_message_free(pn_msg);
+        qd_message_free(msg);
+        return "Error in pn_message_decode";
+    }
 
-    if (strcmp(pn_message_get_address(pn_msg), "test_addr_0") != 0)
+    if (strcmp(pn_message_get_address(pn_msg), "test_addr_0") != 0) {
+        pn_message_free(pn_msg);
+        qd_message_free(msg);
         return "Address mismatch in received message";
+    }
 
     pn_message_free(pn_msg);
     qd_message_free(msg);
@@ -317,12 +324,18 @@ static char* test_send_message_annotations(void *context)
 
     qd_message_compose_1(msg, "test_addr_0", 0);
     qd_buffer_t *buf = DEQ_HEAD(content->buffers);
-    if (buf == 0) return "Expected a buffer in the test message";
+    if (buf == 0) {
+        qd_message_free(msg);
+        return "Expected a buffer in the test message";
+    }
 
     pn_message_t *pn_msg = pn_message();
     size_t len = flatten_bufs(content);
     int result = pn_message_decode(pn_msg, buffer, len);
-    if (result != 0) return "Error in pn_message_decode";
+    if (result != 0) {
+        qd_message_free(msg);
+        return "Error in pn_message_decode";
+    }
 
     pn_data_t *ma = pn_message_annotations(pn_msg);
     if (!ma) return "Missing message annotations";


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message