[PATCH 01/14] AVIS: Added NULL checks for all tests which caused crashing


Frank Quinn <fquinn.ni@...>
 

This is with the exception of the timer implementation which
has several bugs which have already been fixed in the qpid
queue implementation so the qpid timer should instead simply
be converted into common code to share between avis and qpid
rather than fix the Timer crash we see in MamaMiddlewareC.

Signed-off-by: Frank Quinn <fquinn.ni@...>
---
 mama/c_cpp/src/c/bridge/avis/bridge.c          |  6 ++++--
 mama/c_cpp/src/c/bridge/avis/io.c              |  2 ++
 mama/c_cpp/src/c/bridge/avis/msg.c             |  4 ++++
 mama/c_cpp/src/c/bridge/avis/publisher.c       | 12 ++++++++++--
 mama/c_cpp/src/c/bridge/avis/queue.c           |  8 +++++++-
 mama/c_cpp/src/c/bridge/avis/transportbridge.c |  9 +++++++++
 mama/c_cpp/src/c/payload/avismsg/avispayload.c |  1 +
 7 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/mama/c_cpp/src/c/bridge/avis/bridge.c b/mama/c_cpp/src/c/bridge/avis/bridge.c
index 97cbb08..33dfc17 100644
--- a/mama/c_cpp/src/c/bridge/avis/bridge.c
+++ b/mama/c_cpp/src/c/bridge/avis/bridge.c
@@ -77,8 +77,10 @@ static const char PAYLOAD_IDS[] = {MAMA_PAYLOAD_AVIS,NULL};
 mama_status
 avisBridge_getDefaultPayloadId (char***name, char** id)
 {
-    *name = PAYLOAD_NAMES;
-    *id = PAYLOAD_IDS;
+    if (!name) return MAMA_STATUS_NULL_ARG;
+    if (!id) return MAMA_STATUS_NULL_ARG;
+    *name = PAYLOAD_NAMES;
+    *id = PAYLOAD_IDS;
 
     return MAMA_STATUS_OK;
 }
diff --git a/mama/c_cpp/src/c/bridge/avis/io.c b/mama/c_cpp/src/c/bridge/avis/io.c
index f5d2544..91e7d22 100644
--- a/mama/c_cpp/src/c/bridge/avis/io.c
+++ b/mama/c_cpp/src/c/bridge/avis/io.c
@@ -33,6 +33,7 @@ avisBridgeMamaIo_create(ioBridge*  result,
                          mamaIo     parent,
                          void*      closure)
 {
+    if (!result) return MAMA_STATUS_NULL_ARG;
     *result = 0;
     return MAMA_STATUS_NOT_IMPLEMENTED;
 }
@@ -46,6 +47,7 @@ avisBridgeMamaIo_destroy (ioBridge io)
 mama_status
 avisBridgeMamaIo_getDescriptor (ioBridge io, uint32_t *result)
 {
+    if (!result) return MAMA_STATUS_NULL_ARG;
     *result = 0;
     return MAMA_STATUS_NOT_IMPLEMENTED;
 }
diff --git a/mama/c_cpp/src/c/bridge/avis/msg.c b/mama/c_cpp/src/c/bridge/avis/msg.c
index 675ef6d..5e02673 100644
--- a/mama/c_cpp/src/c/bridge/avis/msg.c
+++ b/mama/c_cpp/src/c/bridge/avis/msg.c
@@ -119,6 +119,7 @@ mama_status
 avisBridgeMamaMsgImpl_setReplyHandle (msgBridge msg, void* result)
 {
     mama_status status = MAMA_STATUS_OK;
+    if (!result) return MAMA_STATUS_NULL_ARG;
 
     CHECK_MSG(msg);
 
@@ -155,6 +156,7 @@ avisBridgeMamaMsg_setSendSubject (msgBridge   msg,
                                   const char* subject)
 {
     mama_status status = MAMA_STATUS_OK;
+    if (!symbol) return MAMA_STATUS_NULL_ARG;
 
     CHECK_MSG(msg);
 
@@ -173,6 +175,7 @@ avisBridgeMamaMsg_setSendSubject (msgBridge   msg,
 mama_status
 avisBridgeMamaMsg_getNativeHandle (msgBridge msg, void** result)
 {
+    if (!result) return MAMA_STATUS_NULL_ARG;
     CHECK_MSG(msg);
     *result = avisMsg(msg)->mAvisMsg;
     return MAMA_STATUS_OK;
@@ -201,6 +204,7 @@ mama_status
 avisBridgeMamaMsg_copyReplyHandle (void* src, void** dest)
 {
     const char* replyAddr = (const char*) src;
+    if (!src || !dest) return MAMA_STATUS_NULL_ARG;
     *dest = (void*) strdup(replyAddr);
     return MAMA_STATUS_OK;
 }
diff --git a/mama/c_cpp/src/c/bridge/avis/publisher.c b/mama/c_cpp/src/c/bridge/avis/publisher.c
index 2e25524..364aa1d 100644
--- a/mama/c_cpp/src/c/bridge/avis/publisher.c
+++ b/mama/c_cpp/src/c/bridge/avis/publisher.c
@@ -233,11 +233,10 @@ avisBridgeMamaPublisher_createByIndex (publisherBridge* result,
                                         void*            nativeQueueHandle,
                                         mamaPublisher    parent)
 {
+    if (!result || !tport || !parent) return MAMA_STATUS_NULL_ARG;
     Elvin* avis = getAvis(tport);
     avisPublisherBridge* publisher = NULL;
 
-    if (!result || !tport) return MAMA_STATUS_NULL_ARG;
-
     CHECK_AVIS(avis);
 
     *result = NULL;
@@ -314,6 +313,8 @@ avisBridgeMamaPublisher_send (publisherBridge publisher, mamaMsg msg)
 {
     mama_status ret = MAMA_STATUS_OK;
 
+    if (!msg) return MAMA_STATUS_NULL_ARG;
+
     CHECK_PUBLISHER(publisher);
 
     ret = avisBridgeMamaPublisherImpl_prepareMessage (&msg);
@@ -348,6 +349,8 @@ avisBridgeMamaPublisher_sendReplyToInbox (publisherBridge  publisher,
     const char*  replyAddr   = NULL;
     mama_status  status;
    
+    if (!request || !reply) return MAMA_STATUS_NULL_ARG;
+
     CHECK_PUBLISHER(publisher);
 
     mamaMsg_getNativeHandle(request, (void**) &requestMsg);
@@ -402,6 +405,7 @@ avisBridgeMamaPublisher_sendReplyToInbox (publisherBridge  publisher,
 mama_status
 avisBridgeMamaPublisher_destroy (publisherBridge publisher)
 {
+    if (!publisher) return MAMA_STATUS_NULL_ARG;
     free ((char*)avisPublisher(publisher)->mSource);
     free ((char*)avisPublisher(publisher)->mTopic);
     free ((char*)avisPublisher(publisher)->mRoot);
@@ -420,6 +424,8 @@ avisBridgeMamaPublisher_sendFromInboxByIndex (publisherBridge publisher,
     const char* replyAddr = NULL;
     mama_status status;
 
+    if (!inbox || !msg) return MAMA_STATUS_NULL_ARG;
+
     CHECK_PUBLISHER(publisher);
 
     status = avisBridgeMamaPublisherImpl_prepareMessage (&msg);
@@ -475,6 +481,8 @@ avisBridgeMamaPublisher_sendReplyToInboxHandle (publisherBridge publisher,
 {
     mama_status status;
 
+    if (!inbox | !reply) return MAMA_STATUS_NULL_ARG;
+
     CHECK_PUBLISHER(publisher);
 
     status = avisBridgeMamaPublisherImpl_prepareMessage (&reply);
diff --git a/mama/c_cpp/src/c/bridge/avis/queue.c b/mama/c_cpp/src/c/bridge/avis/queue.c
index 6416751..e32845f 100644
--- a/mama/c_cpp/src/c/bridge/avis/queue.c
+++ b/mama/c_cpp/src/c/bridge/avis/queue.c
@@ -200,7 +200,8 @@ avisBridgeMamaQueue_enqueueEvent (queueBridge        queue,
 {
     wombatQueueStatus status;
     avisQueueClosure* cl = NULL;
-   
+
+    if (!callback) return MAMA_STATUS_NULL_ARG;
     CHECK_QUEUE(queue);
 
     cl = (avisQueueClosure*)calloc(1, sizeof(avisQueueClosure));
@@ -251,6 +252,7 @@ avisBridgeMamaQueue_setEnqueueCallback (queueBridge        queue,
                                         mamaQueueEnqueueCB callback,
                                         void*              closure)
 {
+    if (!callback) return MAMA_STATUS_NULL_ARG;
     CHECK_QUEUE(queue);
 
     avisQueue(queue)->mEnqueueCb      = callback;
@@ -274,6 +276,7 @@ mama_status
 avisBridgeMamaQueue_getNativeHandle (queueBridge queue,
                                      void**      result)
 {
+    if (!result) return MAMA_STATUS_NULL_ARG;
     CHECK_QUEUE(queue);
     *result = avisQueue(queue)->mQueue;
     return MAMA_STATUS_OK;
@@ -283,6 +286,7 @@ mama_status
 avisBridgeMamaQueue_setHighWatermark (queueBridge queue,
                                       size_t      highWatermark)
 {
+    if (!highWatermark) return MAMA_STATUS_NULL_ARG;
     CHECK_QUEUE(queue);
     return MAMA_STATUS_NOT_IMPLEMENTED;
 }
@@ -291,6 +295,7 @@ mama_status
 avisBridgeMamaQueue_setLowWatermark (queueBridge queue,
                                      size_t lowWatermark)
 {
+    if (!lowWatermark) return MAMA_STATUS_NULL_ARG;
     CHECK_QUEUE(queue);
     return MAMA_STATUS_NOT_IMPLEMENTED;
 }
@@ -298,6 +303,7 @@ avisBridgeMamaQueue_setLowWatermark (queueBridge queue,
 mama_status
 avisBridgeMamaQueue_getEventCount (queueBridge queue, size_t* count)
 {
+    if (!count) return MAMA_STATUS_NULL_ARG;
     CHECK_QUEUE(queue);
     *count = 0;
     wombatQueue_getSize (avisQueue(queue)->mQueue, (int*)count);
diff --git a/mama/c_cpp/src/c/bridge/avis/transportbridge.c b/mama/c_cpp/src/c/bridge/avis/transportbridge.c
index 9b89d65..f456f7e 100644
--- a/mama/c_cpp/src/c/bridge/avis/transportbridge.c
+++ b/mama/c_cpp/src/c/bridge/avis/transportbridge.c
@@ -251,6 +251,7 @@ avisBridgeMamaTransport_getNumLoadBalanceAttributes (
                                           const char* name,
                                           int*        numLoadBalanceAttributes)
 {
+    if (!numLoadBalanceAttributes) return MAMA_STATUS_NULL_ARG;
     *numLoadBalanceAttributes = 0;
     return MAMA_STATUS_OK;
 }
@@ -260,6 +261,7 @@ avisBridgeMamaTransport_getLoadBalanceSharedObjectName (
                                       const char*  name,
                                       const char** loadBalanceSharedObjectName)
 {
+    if (!loadBalanceSharedObjectName) return MAMA_STATUS_NULL_ARG;
     *loadBalanceSharedObjectName = NULL;
     return MAMA_STATUS_OK;
 }
@@ -269,6 +271,7 @@ avisBridgeMamaTransport_getLoadBalanceScheme (
                                     const char*    name,
                                     tportLbScheme* scheme)
 {
+    if (!scheme) return MAMA_STATUS_NULL_ARG;
     *scheme = TPORT_LB_SCHEME_STATIC;
     return MAMA_STATUS_OK;
 }
@@ -283,6 +286,8 @@ avisBridgeMamaTransport_create (transportBridge* result,
     avisTransportBridge* transport  = NULL;
     mamaBridgeImpl*      bridgeImpl = NULL;
     const char*          url        = NULL;
+
+    if (!result || !name) return MAMA_STATUS_NULL_ARG;
    
     transport = (avisTransportBridge*)calloc( 1, sizeof( avisTransportBridge ) );
     if (transport == NULL)
@@ -353,6 +358,8 @@ avisBridgeMamaTransport_destroy (transportBridge transport)
     avisTransportBridge* transportBridge = (avisTransportBridge*) transport;
     avisBridgeImpl*      avisBridge      = NULL;
     mamaBridgeImpl*      bridgeImpl      = NULL;
+
+    if (!transport) return MAMA_STATUS_NULL_ARG;
    
     bridgeImpl = mamaTransportImpl_getBridgeImpl(
         avisTransport(transport)->mTransport);
@@ -506,6 +513,7 @@ mama_status
 avisBridgeMamaTransport_isConnectionIntercepted (mamaConnection connection,
                                                   uint8_t* result)
 {
+    if (!result) return MAMA_STATUS_NULL_ARG;
     *result = 0;
     return MAMA_STATUS_NOT_IMPLEMENTED;
 }
@@ -523,6 +531,7 @@ mama_status
 avisBridgeMamaTransport_getNativeTransport (transportBridge transport,
                                              void**          result)
 {
+    if (!result) return MAMA_STATUS_NULL_ARG;
     CHECK_TRANSPORT(transport);
     *result = avisTransport(transport);
     return MAMA_STATUS_OK;
diff --git a/mama/c_cpp/src/c/payload/avismsg/avispayload.c b/mama/c_cpp/src/c/payload/avismsg/avispayload.c
index 6da49f5..f02920e 100644
--- a/mama/c_cpp/src/c/payload/avismsg/avispayload.c
+++ b/mama/c_cpp/src/c/payload/avismsg/avispayload.c
@@ -2324,6 +2324,7 @@ avismsgFieldPayload_updateDateTime
 {
     CHECK_FIELD(field);
     CHECK_PAYLOAD(msg);
+    CHECK_NULL(value);
     return avisMsg_setDateTime(avisPayload(msg), avisField(field)->mName, 0, value);
 }
 
--
2.4.3

Join Openmama-dev@lists.openmama.org to automatically receive all group messages.