You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2023/01/30 23:00:29 UTC

[qpid-proton] branch main updated (9b4332637 -> 6ae2654a4)

This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git


    from 9b4332637 PROTON-2095: Change CMake build to allow cffi tests to run
     new 82cc883d1 PROTON-2677: [C++ examples] Fix use after free in broker
     new 6ae2654a4 PROTON-2657: Fix an issue found by Coverity

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 cpp/examples/broker.cpp | 6 ++++--
 cpp/src/contexts.cpp    | 4 ++--
 cpp/src/contexts.hpp    | 9 +++++----
 3 files changed, 11 insertions(+), 8 deletions(-)


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


[qpid-proton] 02/02: PROTON-2657: Fix an issue found by Coverity

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 6ae2654a4eebfd3108544775bbc5d40a015665f0
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Mon Jan 30 17:54:50 2023 -0500

    PROTON-2657: Fix an issue found by Coverity
    
    If you try to get  the user_data value before it is set it might be
    uninitialised.
    
    Also improve some pointer usage in contexts to use C++ 11 nullptr.
---
 cpp/src/contexts.cpp | 4 ++--
 cpp/src/contexts.hpp | 9 +++++----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/cpp/src/contexts.cpp b/cpp/src/contexts.cpp
index 4f85ace93..a3b393968 100644
--- a/cpp/src/contexts.cpp
+++ b/cpp/src/contexts.cpp
@@ -66,14 +66,14 @@ void *context::alloc(size_t n) { return pn_class_new(cpp_context_class, n); }
 pn_class_t* context::pn_class() { return cpp_context_class; }
 
 connection_context::connection_context() :
-    container(0), default_session(0), link_gen(0), handler(0), listener_context_(0)
+    container(nullptr), default_session(nullptr), link_gen(nullptr), handler(nullptr), listener_context_(nullptr), user_data_(nullptr)
 {}
 
 reconnect_context::reconnect_context(const reconnect_options_base& ro) :
     reconnect_options_(ro), retries_(0), current_url_(-1), stop_reconnect_(false), reconnected_(false)
 {}
 
-listener_context::listener_context() : listen_handler_(0) {}
+listener_context::listener_context() : listen_handler_(nullptr), user_data_(nullptr) {}
 
 connection_context& connection_context::get(pn_connection_t *c) {
     return ref<connection_context>(id(pn_connection_attachments(c), CONNECTION_CONTEXT));
diff --git a/cpp/src/contexts.hpp b/cpp/src/contexts.hpp
index 02ea76083..7ebab1d7b 100644
--- a/cpp/src/contexts.hpp
+++ b/cpp/src/contexts.hpp
@@ -133,7 +133,9 @@ class listener_context : public context {
 
 class link_context : public context {
   public:
-    link_context() : handler(0), credit_window(10), pending_credit(0), auto_accept(true), auto_settle(true), draining(false) {}
+    link_context() :
+      handler(nullptr), credit_window(10), pending_credit(0), auto_accept(true), auto_settle(true), draining(false), user_data_(nullptr)
+    {}
     static link_context& get(pn_link_t* l);
 
     messaging_handler* handler;
@@ -147,7 +149,7 @@ class link_context : public context {
 
 class session_context : public context {
   public:
-    session_context() : handler(0) {}
+    session_context() : handler(0), user_data_(nullptr) {}
     static session_context& get(pn_session_t* s);
 
     messaging_handler* handler;
@@ -156,10 +158,9 @@ class session_context : public context {
 
 class transfer_context : public context {
   public:
-    transfer_context() : handler(0) {}
+    transfer_context() : user_data_(nullptr) {}
     static transfer_context& get(pn_delivery_t* s);
 
-    messaging_handler* handler;
     void* user_data_;
 };
 


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


[qpid-proton] 01/02: PROTON-2677: [C++ examples] Fix use after free in broker

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 82cc883d1dfa709c52c41cf492d66f78d2efcd06
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Mon Jan 30 17:53:32 2023 -0500

    PROTON-2677: [C++ examples] Fix use after free in broker
---
 cpp/examples/broker.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/cpp/examples/broker.cpp b/cpp/examples/broker.cpp
index 6c4e24785..32591ebbb 100644
--- a/cpp/examples/broker.cpp
+++ b/cpp/examples/broker.cpp
@@ -114,6 +114,8 @@ public:
     }
     void unsubscribed() {
         DOUT(std::cerr << "Sender:   " << this << " deleting\n";);
+        sender_.user_data(nullptr);
+        sender_.close();
         delete this;
     }
 };
@@ -383,7 +385,7 @@ public:
         // Unsubscribe all senders that belong to session.
         for (proton::sender_iterator i = session.senders().begin(); i != session.senders().end(); ++i) {
             Sender* s = Sender::get(*i);
-            if (s->queue_) {
+            if (s && s->queue_) {
                 auto q = s->queue_;
                 s->queue_->add([=]{q->unsubscribe(s);});
             }
@@ -399,7 +401,7 @@ public:
         // Unsubscribe all senders.
         for (proton::sender_iterator i = t.connection().senders().begin(); i != t.connection().senders().end(); ++i) {
             Sender* s = Sender::get(*i);
-            if (s->queue_) {
+            if (s && s->queue_) {
                 auto q = s->queue_;
                 s->queue_->add([=]{q->unsubscribe(s);});
             }


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