summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsjiang <sjiang@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2006-03-28 21:44:19 +0000
committersjiang <sjiang@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2006-03-28 21:44:19 +0000
commit8b71bb34ab55f9920796e31517b5aca0922628c8 (patch)
tree701f5ff5c7a7960e9094264c12a6bd18588ea98d
parent76d9fa06ecc2176bb3a8214f4c9b9e6295f9171c (diff)
downloadATCD-8b71bb34ab55f9920796e31517b5aca0922628c8.tar.gz
ChangeLog Tag: Tue Mar 28 21:30:01 UTC 2006 jiang,shanshan <shanshan.jiang@vanderbilt.edu>
-rw-r--r--ChangeLog13
-rw-r--r--THANKS1
-rw-r--r--ace/Log_Msg.cpp20
-rw-r--r--ace/Log_Msg.h2
-rw-r--r--ace/Log_Record.cpp21
-rw-r--r--ace/Log_Record.h4
-rw-r--r--ace/Log_Record.inl2
7 files changed, 50 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 8fabf3d6c35..81f795e6895 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Tue Mar 28 21:30:01 UTC 2006 jiang,shanshan <shanshan.jiang@vanderbilt.edu>
+
+ * ace/Log_Msg.cpp
+ * ace/Log_Msg.h
+ * ace/Log_Record.cpp
+ * ace/Log_Record.h
+ * ace/Log_Record.inl
+ Updated these files to solve the stack overflow problem in ACE_Log_Msg
+ and ACE_Log_Record. Moves buffers that can be large in stack in malloced
+ memory.
+ Thanks to qwerty <qwerty0987654321 at mail dot ru> for motivating and
+ suggesting the fix to this problem.
+
Tue Mar 28 18:34:26 UTC 2006 Wallace Zhang <zhangw@ociweb.com>
* bin/tao_other_tests.lst:
diff --git a/THANKS b/THANKS
index 6ce4993e0ca..3c24fec5f50 100644
--- a/THANKS
+++ b/THANKS
@@ -2087,6 +2087,7 @@ Roopa Pundaleeka <roopa at txcorp dot com>
JR Andreassen <janrune at io doc com>
Mockey Chen <mockey dot chen @ google dot com>
Vincent Joseph <deskamess at yahoo dot com>
+qwerty <qwerty0987654321 at mail dot ru>
I would particularly like to thank Paul Stephenson, who worked with me
at Ericsson in the early 1990's. Paul devised the recursive Makefile
diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp
index 1e72c3d3876..0372afe1992 100644
--- a/ace/Log_Msg.cpp
+++ b/ace/Log_Msg.cpp
@@ -629,6 +629,7 @@ ACE_Log_Msg::ACE_Log_Msg (void)
: status_ (0),
errnum_ (0),
linenum_ (0),
+ msg_ (0),
restart_ (1), // Restart by default...
ostream_ (0),
msg_callback_ (0),
@@ -668,6 +669,8 @@ ACE_Log_Msg::ACE_Log_Msg (void)
this->timestamp_ = 2;
}
}
+
+ ACE_NEW_NORETURN (this->msg_, ACE_TCHAR[ACE_MAXLOGMSGLEN+1]);
}
ACE_Log_Msg::~ACE_Log_Msg (void)
@@ -736,6 +739,11 @@ ACE_Log_Msg::~ACE_Log_Msg (void)
ostream_ = 0;
}
#endif
+
+ if (this->msg_)
+ {
+ delete[] this->msg_;
+ }
}
// Open the sender-side of the message queue.
@@ -1973,7 +1981,7 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
// Check that memory was not corrupted, if it corrupted we can't log anything
// anymore because all our members could be corrupted.
- if (bp >= this->msg_ + sizeof this->msg_)
+ if (bp >= (this->msg_ + ACE_MAXLOGMSGLEN+1))
{
abort_prog = 1;
ACE_OS::fprintf (stderr,
@@ -2159,9 +2167,9 @@ ACE_Log_Msg::log_hexdump (ACE_Log_Priority log_priority,
if (this->log_priority_enabled (log_priority) == 0)
return 0;
- ACE_TCHAR buf[ACE_Log_Record::MAXLOGMSGLEN -
- ACE_Log_Record::VERBOSE_LEN - 58];
- // 58 for the HEXDUMP header;
+ ACE_TCHAR* buf;
+ size_t buf_sz = ACE_Log_Record::MAXLOGMSGLEN - ACE_Log_Record::VERBOSE_LEN - 58;
+ ACE_NEW_RETURN (buf, ACE_TCHAR[buf_sz], -1);
ACE_TCHAR *msg_buf;
const size_t text_sz = text ? ACE_OS::strlen(text) : 0;
@@ -2172,7 +2180,7 @@ ACE_Log_Msg::log_hexdump (ACE_Log_Priority log_priority,
buf[0] = 0; // in case size = 0
const size_t len = ACE::format_hexdump
- (buffer, size, buf, sizeof (buf) / sizeof (ACE_TCHAR) - text_sz);
+ (buffer, size, buf, buf_sz / sizeof (ACE_TCHAR) - text_sz);
int sz = 0;
@@ -2452,7 +2460,7 @@ void
ACE_Log_Msg::msg (const ACE_TCHAR *m)
{
ACE_OS::strsncpy (this->msg_, m,
- (sizeof this->msg_ / sizeof (ACE_TCHAR)));
+ ((ACE_MAXLOGMSGLEN+1) / sizeof (ACE_TCHAR)));
}
ACE_Log_Msg_Callback *
diff --git a/ace/Log_Msg.h b/ace/Log_Msg.h
index 6d65dbf3e6f..0a9b9be3f9f 100644
--- a/ace/Log_Msg.h
+++ b/ace/Log_Msg.h
@@ -580,7 +580,7 @@ private:
/// The log message, which resides in thread-specific storage. Note
/// that only the current log message is stored here -- it will be
/// overwritten by the subsequent call to log().
- ACE_TCHAR msg_[ACE_MAXLOGMSGLEN + 1]; // Add one for NUL-terminator.
+ ACE_TCHAR* msg_; // Add one for NUL-terminator.
/// Indicates whether we should restart system calls that are
/// interrupted.
diff --git a/ace/Log_Record.cpp b/ace/Log_Record.cpp
index d4b87b50ed8..bb0769abd91 100644
--- a/ace/Log_Record.cpp
+++ b/ace/Log_Record.cpp
@@ -16,6 +16,8 @@
# include "ace/streams.h"
#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
+#include "ace/OS_Memory.h"
+
ACE_RCSID(ace, Log_Record, "$Id$")
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -118,7 +120,7 @@ ACE_Log_Record::msg_data (const ACE_TCHAR *data)
{
// ACE_TRACE ("ACE_Log_Record::msg_data");
ACE_OS::strsncpy (this->msg_data_, data,
- (sizeof this->msg_data_ / sizeof (ACE_TCHAR)));
+ (MAXLOGMSGLEN / sizeof (ACE_TCHAR)));
this->round_up ();
}
@@ -132,6 +134,7 @@ ACE_Log_Record::ACE_Log_Record (ACE_Log_Priority lp,
pid_ (ACE_UINT32 (p))
{
// ACE_TRACE ("ACE_Log_Record::ACE_Log_Record");
+ ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]);
}
ACE_Log_Record::ACE_Log_Record (ACE_Log_Priority lp,
@@ -144,6 +147,7 @@ ACE_Log_Record::ACE_Log_Record (ACE_Log_Priority lp,
pid_ (ACE_UINT32 (p))
{
// ACE_TRACE ("ACE_Log_Record::ACE_Log_Record");
+ ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]);
}
void
@@ -151,7 +155,7 @@ ACE_Log_Record::round_up (void)
{
// ACE_TRACE ("ACE_Log_Record::round_up");
// Determine the length of the payload.
- size_t len = (sizeof (*this) - sizeof (this->msg_data_))
+ size_t len = (sizeof (*this) - MAXLOGMSGLEN)
+ (sizeof (ACE_TCHAR) * ((ACE_OS::strlen (this->msg_data_) + 1)));
// Round up to the alignment.
@@ -168,6 +172,7 @@ ACE_Log_Record::ACE_Log_Record (void)
pid_ (0)
{
// ACE_TRACE ("ACE_Log_Record::ACE_Log_Record");
+ ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]);
}
int
@@ -251,7 +256,9 @@ ACE_Log_Record::print (const ACE_TCHAR host_name[],
u_long verbose_flag,
FILE *fp)
{
- ACE_TCHAR verbose_msg [MAXVERBOSELOGMSGLEN];
+ ACE_TCHAR* verbose_msg;
+ ACE_NEW_RETURN (verbose_msg,ACE_TCHAR[MAXVERBOSELOGMSGLEN], -1);
+
int result = this->format_msg (host_name,
verbose_flag,
verbose_msg);
@@ -272,6 +279,8 @@ ACE_Log_Record::print (const ACE_TCHAR host_name[],
}
}
+ delete[] verbose_msg;
+
return result;
}
@@ -282,7 +291,9 @@ ACE_Log_Record::print (const ACE_TCHAR host_name[],
u_long verbose_flag,
ACE_OSTREAM_TYPE &s)
{
- ACE_TCHAR verbose_msg [MAXVERBOSELOGMSGLEN];
+ ACE_TCHAR* verbose_msg;
+ ACE_NEW_RETURN (verbose_msg,ACE_TCHAR[MAXVERBOSELOGMSGLEN], -1);
+
int result = this->format_msg (host_name, verbose_flag, verbose_msg);
if (result == 0)
@@ -292,6 +303,8 @@ ACE_Log_Record::print (const ACE_TCHAR host_name[],
s.flush ();
}
+ delete[] verbose_msg;
+
return result;
}
diff --git a/ace/Log_Record.h b/ace/Log_Record.h
index 5a2f25acd41..ef6b8104711 100644
--- a/ace/Log_Record.h
+++ b/ace/Log_Record.h
@@ -40,7 +40,7 @@ public:
enum
{
/// Maximum size of a logging message.
- MAXLOGMSGLEN = ACE_MAXLOGMSGLEN,
+ MAXLOGMSGLEN = ACE_MAXLOGMSGLEN+1,
/// Most restrictive alignment.
ALIGN_WORDB = 8,
@@ -187,7 +187,7 @@ private:
ACE_UINT32 pid_;
/// Logging record data
- ACE_TCHAR msg_data_[MAXLOGMSGLEN + 1]; // Add one for NUL-terminator.
+ ACE_TCHAR* msg_data_; // Add one for NUL-terminator.
};
diff --git a/ace/Log_Record.inl b/ace/Log_Record.inl
index 6cb36d488c1..b31af15384a 100644
--- a/ace/Log_Record.inl
+++ b/ace/Log_Record.inl
@@ -12,6 +12,8 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
ACE_Log_Record::~ACE_Log_Record (void)
{
+ if (this->msg_data_)
+ delete[] this->msg_data_;
}
ACE_INLINE void