This patch fixes a leak of ipc connections (shared memory) in the
saMsg service library code.

In saMsgMessageGet and saMsgMessageSendReceive, if the response from
the exec indicated that there was an error, the library code would
call disconnect without first doing a put. This could easily be
reproduced by calling saMsgMessageGet in a loop. Eventually shared
memory would be exhausted resulting in a bus error.

Ryan

Index: lib/msg.c
===================================================================
--- lib/msg.c   (revision 1879)
+++ lib/msg.c   (working copy)
@@ -1407,12 +1407,15 @@
                &iov,
                1,
                &buffer);
+       if (error != SA_AIS_OK) {
+               goto error_disconnect;
+       }
 
        res_lib_msg_messageget = buffer;
 
        if (res_lib_msg_messageget->header.error != SA_AIS_OK) {
                error = res_lib_msg_messageget->header.error;
-               goto error_disconnect;
+               goto error_ipc_put;
        }
 
        if (message->data == NULL) {
@@ -1583,28 +1586,20 @@
        iov[1].iov_base = sendMessage->data;
        iov[1].iov_len = sendMessage->size;
 
-       /*
-       error = coroipcc_msg_send_reply_receive (
-               msgInstance->ipc_handle,
-               iov,
-               2,
-               &res_lib_msg_messagesendreceive,
-               sizeof (struct res_lib_msg_messagesendreceive));
-       */
-
        error = coroipcc_msg_send_reply_receive_in_buf_get (
                ipc_handle,
                iov,
                2,
                &buffer);
+       if (error != SA_AIS_OK) {
+               goto error_disconnect;
+       }
 
-       /* if (error != SA_AIS_OK) */
-
        res_lib_msg_messagesendreceive = buffer;
 
        if (res_lib_msg_messagesendreceive->header.error != SA_AIS_OK) {
                error = res_lib_msg_messagesendreceive->header.error;
-               goto error_disconnect;
+               goto error_ipc_put;
        }
 
        if (receiveMessage->data == NULL) {
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to