[Openais] [PATCH] fix buffer overrun in test agent.

Angus Salkeld asalkeld at redhat.com
Mon Mar 8 12:08:27 PST 2010


Also to make debugging easier:
1) don't stop abrt
2) fix debug message
3) catch a failed message to the TA and fail the test.

Signed-off-by: Angus Salkeld <asalkeld at redhat.com>
---
 cts/agents/cpg_test_agent.c |    8 ++++----
 cts/corosync.py             |    4 +---
 cts/corotests.py            |    5 ++++-
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/cts/agents/cpg_test_agent.c b/cts/agents/cpg_test_agent.c
index c6dd165..593aadc 100644
--- a/cts/agents/cpg_test_agent.c
+++ b/cts/agents/cpg_test_agent.c
@@ -72,7 +72,7 @@ typedef struct {
 	char payload[1];
 } msg_t;
 
-#define LOG_STR_SIZE 128
+#define LOG_STR_SIZE 256
 typedef struct {
 	char log[LOG_STR_SIZE];
 	struct list_head list;
@@ -129,7 +129,7 @@ static void delivery_callback (
 
 	log_pt = malloc (sizeof(log_entry_t));
 	list_init (&log_pt->list);
-	snprintf (log_pt->log, 128, "%d:%d:%d:%d;",
+	snprintf (log_pt->log, LOG_STR_SIZE, "%d:%d:%d:%d;",
 		msg_pt->nodeid, msg_pt->pid, msg_pt->seq, status);
 	list_add_tail (&log_pt->list, &msg_log_head);
 	total_stored_msgs++;
@@ -155,7 +155,7 @@ static void config_change_callback (
 
 		log_pt = malloc (sizeof(log_entry_t));
 		list_init (&log_pt->list);
-		snprintf (log_pt->log, 256, "%s,%d,%d,left",
+		snprintf (log_pt->log, LOG_STR_SIZE, "%s,%d,%d,left",
 			groupName->value, left_list[i].nodeid,left_list[i].pid);
 		list_add_tail(&log_pt->list, &config_chg_log_head);
 	}
@@ -164,7 +164,7 @@ static void config_change_callback (
 
 		log_pt = malloc (sizeof(log_entry_t));
 		list_init (&log_pt->list);
-		snprintf (log_pt->log, 256, "%s,%d,%d,join",
+		snprintf (log_pt->log, LOG_STR_SIZE, "%s,%d,%d,join",
 			groupName->value, joined_list[i].nodeid,joined_list[i].pid);
 		list_add_tail (&log_pt->list, &config_chg_log_head);
 	}
diff --git a/cts/corosync.py b/cts/corosync.py
index 09c55af..21cb5b5 100644
--- a/cts/corosync.py
+++ b/cts/corosync.py
@@ -261,7 +261,6 @@ class corosync_flatiron(ClusterManager):
         for node in self.Env["nodes"]:
             self.ShouldBeStatus[node] = ""
             self.unisolate_node(node)
-            self.rsh(node, 'service abrtd stop', 1)
             self.StataCM(node)
 
     def HasQuorum(self, node_list):
@@ -355,7 +354,6 @@ class TestAgent(object):
     
     def start(self):
         '''Set up the given ScenarioComponent'''
-
         self.env.debug('test agent: start (' + self.node + ')')
         self.sock = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
         ip = socket.gethostbyname(self.node)
@@ -369,7 +367,7 @@ class TestAgent(object):
                 is_connected = True
             except socket.error, msg:
                 if retries > 5:
-                    self.env.debug( "Retried " + str(retries) + " times. Error: " + msg )
+                    self.env.debug("Retried " + str(retries) + " times. Error: " + str(msg))
                 time.sleep(1)
         self.started = True
         self.used = False
diff --git a/cts/corotests.py b/cts/corotests.py
index 5169d2a..d950d5c 100644
--- a/cts/corotests.py
+++ b/cts/corotests.py
@@ -96,7 +96,10 @@ class CpgConfigChangeBase(CoroTest):
         printit = 0
         self.CM.log("Waiting for config change on " + self.listener)
         while not found:
-            event = self.CM.agent[self.listener].read_config_event()
+            try:
+                event = self.CM.agent[self.listener].read_config_event()
+            except:
+                return self.failure('connection to test agent failed.')
             if not event == None:
                 self.CM.debug("RECEIVED: " + str(event))
             if event == None:
-- 
1.6.6.1




More information about the Openais mailing list