[PATCH 7/7] Update to getProcessInfo() to include NULL check.


Damian Maguire <DMaguire@...>
 

Cheers Gary, raised this as BZ137

D

From: Gary Molloy <GMolloy@...>
Date: Tuesday, June 24, 2014 10:53 AM
To: "openmama-dev@..." <openmama-dev@...>
Subject: [Openmama-dev] [PATCH 7/7] Update to getProcessInfo() to include NULL check.

Testing

 

This was not easily re-creatable but could be seen using enterprise products.

The issue was seen to be resolved with the patch supplied.

General regression and unittests were used to test no other effects were seen.

 

 

From 0208c8957252d5e2b728e9a48d23017b31ef1e94 Mon Sep 17 00:00:00 2001

From: Gary Molloy <gmolloy@...>

Date: Mon, 23 Jun 2014 17:00:09 +0100

Subject: [PATCH 7/7] Update to getProcessInfo() to include NULL check.

 

[OMAMA-263]

 

Description - Added a NULL check into getProcessInfo() to protect from coring when this function fails.

 

Signed-off-by: Gary Molloy <gmolloy@...>

---

common/c_cpp/src/c/linux/machine.c | 5 +++++

1 file changed, 5 insertions(+)

 

diff --git a/common/c_cpp/src/c/linux/machine.c b/common/c_cpp/src/c/linux/machine.c

index 29f0655..0a9b6b9 100644

--- a/common/c_cpp/src/c/linux/machine.c

+++ b/common/c_cpp/src/c/linux/machine.c

@@ -431,6 +431,11 @@ int getProcessInfo(int pid ,memVals *memV,cpuVals *cpuV,int childFlag)

     /* parse out the status */

     p = buffer;

     p = strchr(p, '(')+1;                       /* skip pid */

+    if (p==NULL)

+    {

+        /* Process has exited since the pid was initially obtained */

+        return 0;

+    }

     {

         char name[64];

         char *q = strrchr(p, ')'); /*process name*/

--

1.8.3.1

 


This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange Group, Inc. (ICE), NYSE Euronext or any of their subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.

This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of Intercontinental Exchange, Inc. (ICE), Euronext or any of their subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.


Gary Molloy <GMolloy@...>
 

Testing

 

This was not easily re-creatable but could be seen using enterprise products.

The issue was seen to be resolved with the patch supplied.

General regression and unittests were used to test no other effects were seen.

 

 

From 0208c8957252d5e2b728e9a48d23017b31ef1e94 Mon Sep 17 00:00:00 2001

From: Gary Molloy <gmolloy@...>

Date: Mon, 23 Jun 2014 17:00:09 +0100

Subject: [PATCH 7/7] Update to getProcessInfo() to include NULL check.

 

[OMAMA-263]

 

Description - Added a NULL check into getProcessInfo() to protect from coring when this function fails.

 

Signed-off-by: Gary Molloy <gmolloy@...>

---

common/c_cpp/src/c/linux/machine.c | 5 +++++

1 file changed, 5 insertions(+)

 

diff --git a/common/c_cpp/src/c/linux/machine.c b/common/c_cpp/src/c/linux/machine.c

index 29f0655..0a9b6b9 100644

--- a/common/c_cpp/src/c/linux/machine.c

+++ b/common/c_cpp/src/c/linux/machine.c

@@ -431,6 +431,11 @@ int getProcessInfo(int pid ,memVals *memV,cpuVals *cpuV,int childFlag)

     /* parse out the status */

     p = buffer;

     p = strchr(p, '(')+1;                       /* skip pid */

+    if (p==NULL)

+    {

+        /* Process has exited since the pid was initially obtained */

+        return 0;

+    }

     {

         char name[64];

         char *q = strrchr(p, ')'); /*process name*/

--

1.8.3.1

 


This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange Group, Inc. (ICE), NYSE Euronext or any of their subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.