You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2017/11/13 22:08:42 UTC
qpid-dispatch git commit: DISPATCH-847 - Be more defensive in the use
of link mask bits.
Repository: qpid-dispatch
Updated Branches:
refs/heads/master 8e8c46ac0 -> c8c4587eb
DISPATCH-847 - Be more defensive in the use of link mask bits.
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/c8c4587e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/c8c4587e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/c8c4587e
Branch: refs/heads/master
Commit: c8c4587eb608e75f3240542005d5262f0b939fc3
Parents: 8e8c46a
Author: Ted Ross <tr...@redhat.com>
Authored: Mon Nov 13 12:22:56 2017 -0500
Committer: Ted Ross <tr...@redhat.com>
Committed: Mon Nov 13 12:22:56 2017 -0500
----------------------------------------------------------------------
include/qpid/dispatch/bitmask.h | 4 ++++
src/bitmask.c | 6 ++++++
src/router_core/connections.c | 11 +++++++----
3 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/c8c4587e/include/qpid/dispatch/bitmask.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/bitmask.h b/include/qpid/dispatch/bitmask.h
index 91239ec..dd7d3df 100644
--- a/include/qpid/dispatch/bitmask.h
+++ b/include/qpid/dispatch/bitmask.h
@@ -27,6 +27,8 @@
*@{
*/
+#include <stdbool.h>
+
/** A bit mask */
typedef struct qd_bitmask_t qd_bitmask_t;
@@ -46,6 +48,8 @@ int qd_bitmask_value(qd_bitmask_t *b, int bitnum);
int qd_bitmask_first_set(qd_bitmask_t *b, int *bitnum);
int qd_bitmask_cardinality(const qd_bitmask_t *b);
+bool qd_bitmask_valid_bit_value(int bitnum);
+
int _qdbm_start(qd_bitmask_t *b);
void _qdbm_next(qd_bitmask_t *b, int *v);
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/c8c4587e/src/bitmask.c
----------------------------------------------------------------------
diff --git a/src/bitmask.c b/src/bitmask.c
index 7967fbb..1939953 100644
--- a/src/bitmask.c
+++ b/src/bitmask.c
@@ -152,6 +152,12 @@ int qd_bitmask_cardinality(const qd_bitmask_t *b)
}
+bool qd_bitmask_valid_bit_value(int bitnum)
+{
+ return (bitnum >= 0 && bitnum < QD_BITMASK_BITS);
+}
+
+
int _qdbm_start(qd_bitmask_t *b)
{
int v;
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/c8c4587e/src/router_core/connections.c
----------------------------------------------------------------------
diff --git a/src/router_core/connections.c b/src/router_core/connections.c
index 5b2a8c8..2c7200b 100644
--- a/src/router_core/connections.c
+++ b/src/router_core/connections.c
@@ -776,10 +776,12 @@ static void qdr_link_cleanup_CT(qdr_core_t *core, qdr_connection_t *conn, qdr_li
// If this link is involved in inter-router communication, remove its reference
// from the core mask-bit tables
//
- if (link->link_type == QD_LINK_CONTROL)
- core->control_links_by_mask_bit[conn->mask_bit] = 0;
- if (link->link_type == QD_LINK_ROUTER)
- core->data_links_by_mask_bit[conn->mask_bit] = 0;
+ if (qd_bitmask_valid_bit_value(conn->mask_bit)) {
+ if (link->link_type == QD_LINK_CONTROL)
+ core->control_links_by_mask_bit[conn->mask_bit] = 0;
+ if (link->link_type == QD_LINK_ROUTER)
+ core->data_links_by_mask_bit[conn->mask_bit] = 0;
+ }
//
// Clean up the work list
@@ -1340,6 +1342,7 @@ static void qdr_link_inbound_first_attach_CT(qdr_core_t *core, qdr_action_t *act
// Reject any attaches of inter-router links that arrive on connections that are not inter-router.
//
if (((link->link_type == QD_LINK_CONTROL || link->link_type == QD_LINK_ROUTER) && conn->role != QDR_ROLE_INTER_ROUTER)) {
+ link->link_type = QD_LINK_ENDPOINT; // Demote the link type to endpoint if this is not an inter-router connection
qdr_link_outbound_detach_CT(core, link, 0, QDR_CONDITION_FORBIDDEN, true);
qdr_terminus_free(source);
qdr_terminus_free(target);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org