If a real "const SaNameT" is passed into API calls, the agent seg faults.
Code in the agent is writing into the "const SaNameT" pointer which is
stored in read-only memory.
Allow a real "const SaNameT" to be passed into API calls.
---
src/msg/agent/mqa_api.c | 32 --------------------------------
src/msg/agent/mqa_def.h | 7 -------
src/msg/apitest/test_saMsgVersionT.cc | 4 ++--
3 files changed, 2 insertions(+), 41 deletions(-)
diff --git a/src/msg/agent/mqa_api.c b/src/msg/agent/mqa_api.c
index d211b77..5ef238a 100644
--- a/src/msg/agent/mqa_api.c
+++ b/src/msg/agent/mqa_api.c
@@ -711,7 +711,6 @@ saMsgQueueOpen(SaMsgHandleT msgHandle, const SaNameT
*queueName,
return rc;
}
- m_MQSV_SET_SANAMET(queueName);
TRACE_1("queueName %s", queueName->value);
if (strncmp((char *)queueName->value, "safMq=", 6)) {
@@ -1011,7 +1010,6 @@ saMsgQueueOpenAsync(SaMsgHandleT msgHandle, SaInvocationT
invocation,
return rc;
}
- m_MQSV_SET_SANAMET(queueName);
TRACE_1("queueName %s ", queueName->value);
if (strncmp((char *)queueName->value, "safMq=", 6)) {
@@ -1370,7 +1368,6 @@ SaAisErrorT saMsgQueueStatusGet(SaMsgHandleT msgHandle,
return rc;
}
- m_MQSV_SET_SANAMET(queueName);
TRACE_1("queueName %s ", queueName->value);
/* retrieve MQA CB */
@@ -1667,7 +1664,6 @@ SaAisErrorT saMsgQueueUnlink(SaMsgHandleT msgHandle,
const SaNameT *queueName)
return rc;
}
- m_MQSV_SET_SANAMET(queueName);
TRACE_1("queueName %s ", queueName->value);
/* retrieve MQA CB */
@@ -2189,9 +2185,6 @@ SaAisErrorT mqa_send_message(SaMsgHandleT msgHandle,
const SaNameT *destination,
return rc;
}
- /* To memset the bytes to zero other than the length bytes in the
- * SaNameT Structure */
- m_MQSV_SET_SANAMET(destination);
TRACE_1("destination queue name %s", destination->value);
if (m_MQSV_IS_ACKFLAGS_NOT_VALID(ackFlags)) {
@@ -3527,9 +3520,6 @@ SaAisErrorT saMsgMessageSendReceive(SaMsgHandleT
msgHandle,
return rc;
}
- /* To memset the bytes to zero other than the length bytes in the
- * SaNameT Structure */
- m_MQSV_SET_SANAMET(destination);
TRACE_1("Message send to queueName %s", destination->value);
if (m_NCS_SA_IS_VALID_TIME_DURATION(timeout) == false) {
@@ -4487,9 +4477,6 @@ SaAisErrorT saMsgQueueGroupCreate(SaMsgHandleT msgHandle,
return SA_AIS_ERR_INVALID_PARAM;
}
- /* To memset the bytes to zero other than the length bytes in the
- * SaNameT Structure */
- m_MQSV_SET_SANAMET(queueGroupName);
TRACE_1("queueGroupName %s", queueGroupName->value);
if (queueGroupName->length == 0) {
@@ -4636,9 +4623,6 @@ SaAisErrorT saMsgQueueGroupDelete(SaMsgHandleT msgHandle,
"ERR_INVALID_PARAM: queueGroupName exceeds character 256");
return SA_AIS_ERR_INVALID_PARAM;
}
- /* To memset the bytes to zero other than the length bytes in the
- * SaNameT Structure */
- m_MQSV_SET_SANAMET(queueGroupName);
TRACE_1("queueGroupName %s", queueGroupName->value);
/* retrieve MQA CB */
@@ -4771,11 +4755,6 @@ SaAisErrorT saMsgQueueGroupInsert(SaMsgHandleT msgHandle,
return SA_AIS_ERR_INVALID_PARAM;
}
- /* To memset the bytes to zero other than the length bytes in the
- * SaNameT Structure */
- m_MQSV_SET_SANAMET(queueGroupName);
-
- m_MQSV_SET_SANAMET(queueName);
TRACE_1("queueGroupName %s queueName %s", queueGroupName->value,
queueName->value);
@@ -4907,11 +4886,6 @@ SaAisErrorT saMsgQueueGroupRemove(SaMsgHandleT msgHandle,
return SA_AIS_ERR_INVALID_PARAM;
}
- /* To memset the bytes to zero other than the length bytes in the
- * SaNameT Structure */
- m_MQSV_SET_SANAMET(queueGroupName);
-
- m_MQSV_SET_SANAMET(queueName);
TRACE_1("queueGroupName %s queueName %s", queueGroupName->value,
queueName->value);
@@ -5045,9 +5019,6 @@ saMsgQueueGroupTrack(SaMsgHandleT msgHandle, const
SaNameT *queueGroupName,
return SA_AIS_ERR_INVALID_PARAM;
}
- /* To memset the bytes to zero other than the length bytes in the
- * SaNameT Structure */
- m_MQSV_SET_SANAMET(queueGroupName);
TRACE_1("queueGroupName %s", queueGroupName->value);
if (!(trackFlags &
@@ -5386,9 +5357,6 @@ SaAisErrorT saMsgQueueGroupTrackStop(SaMsgHandleT
msgHandle,
return SA_AIS_ERR_INVALID_PARAM;
}
- /* To memset the bytes to zero other than the length bytes in the
- * SaNameT Structure */
- m_MQSV_SET_SANAMET(queueGroupName);
TRACE_1("queueGroupName %s", queueGroupName->value);
/* retrieve MQA CB */
diff --git a/src/msg/agent/mqa_def.h b/src/msg/agent/mqa_def.h
index 94d72c8..e2ea1c4 100644
--- a/src/msg/agent/mqa_def.h
+++ b/src/msg/agent/mqa_def.h
@@ -48,13 +48,6 @@
#define m_MQSV_MQA_RETRIEVE_MQA_CB \
ncshm_take_hdl(NCS_SERVICE_ID_MQA, gl_mqa_hdl)
#define m_MQSV_MQA_GIVEUP_MQA_CB ncshm_give_hdl(gl_mqa_hdl)
-/* to memset the name->value[length] to remaining bytes till the end of the
- * array */
-#define m_MQSV_SET_SANAMET(name) \
- { \
- memset((void *)&name->value[name->length], 0, \
- (size_t)(SA_MAX_NAME_LENGTH - name->length)); \
- }
/* function prototypes for client handling*/
MQA_CLIENT_INFO *mqa_client_tree_find_and_add(MQA_CB *mqa_cb,
diff --git a/src/msg/apitest/test_saMsgVersionT.cc
b/src/msg/apitest/test_saMsgVersionT.cc
index 8166d61..f3c7b05 100644
--- a/src/msg/apitest/test_saMsgVersionT.cc
+++ b/src/msg/apitest/test_saMsgVersionT.cc
@@ -12,8 +12,8 @@ static void saMsgVersion_01(void) {
SaAisErrorT rc = saMsgInitialize(&msgHandle, 0, &msg1_1);
assert(rc == SA_AIS_OK);
- SaNameT queueGroupName = {sizeof("safMqg=messageQGroup") - 1,
- "safMqg=messageQGroup"};
+ const SaNameT queueGroupName = {sizeof("safMqg=messageQGroup") - 1,
+ "safMqg=messageQGroup"};
rc = saMsgQueueGroupCreate(msgHandle, &queueGroupName,
SA_MSG_QUEUE_GROUP_ROUND_ROBIN);
--
2.9.5
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel