Permalink
Browse files

Fixed buffer overflow problem with XMLString::replaceTokens. See XALA…

…NC-698.

git-svn-id: https://svn.apache.org/repos/asf/xalan/c/trunk@944709 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 3d7d467 commit cab8516623e1f46892221a53bc3a2e1b61428c48 David N Berton committed May 15, 2010
Showing with 13 additions and 17 deletions.
  1. +13 −17 src/xalanc/PlatformSupport/XalanMessageLoader.cpp
@@ -39,13 +39,9 @@
#error You must provide a message loader
#endif
-
XALAN_CPP_NAMESPACE_BEGIN
-
-
-#define MAX_MESSAGE_LEN 1024
-
+static const size_t kMaxMessageLength = 1024;
XalanMessageLoader* XalanMessageLoader::s_msgLoader = 0;
@@ -105,13 +101,13 @@ XalanMessageLoader::getMessage(
{
assert(s_msgLoader != 0);
- XalanDOMChar sBuffer[MAX_MESSAGE_LEN];
+ XalanDOMChar sBuffer[kMaxMessageLength + 1];
s_msgLoader->load(
msgToLoad,
theResultMessage.getMemoryManager(),
sBuffer,
- MAX_MESSAGE_LEN,
+ kMaxMessageLength,
repText1.c_str());
theResultMessage.assign(sBuffer);
@@ -130,13 +126,13 @@ XalanMessageLoader::getMessage(
{
assert(s_msgLoader != 0);
- XalanDOMChar sBuffer[MAX_MESSAGE_LEN];
+ XalanDOMChar sBuffer[kMaxMessageLength + 1];
s_msgLoader->load(
msgToLoad,
theResultMessage.getMemoryManager(),
sBuffer,
- MAX_MESSAGE_LEN,
+ kMaxMessageLength,
repText1.c_str(),
repText2.c_str());
@@ -157,13 +153,13 @@ XalanMessageLoader::getMessage(
{
assert(s_msgLoader != 0);
- XalanDOMChar sBuffer[MAX_MESSAGE_LEN];
+ XalanDOMChar sBuffer[kMaxMessageLength + 1];
s_msgLoader->load(
msgToLoad,
theResultMessage.getMemoryManager(),
sBuffer,
- MAX_MESSAGE_LEN,
+ kMaxMessageLength,
repText1.c_str(),
repText2.c_str(),
repText3.c_str());
@@ -183,11 +179,11 @@ XalanMessageLoader::getMessage(
{
assert(s_msgLoader != 0);
- XalanDOMChar sBuffer[MAX_MESSAGE_LEN];
+ XalanDOMChar sBuffer[kMaxMessageLength + 1];
s_msgLoader->loadMsg(msgToLoad,
sBuffer,
- MAX_MESSAGE_LEN) ;
+ kMaxMessageLength) ;
theResultMessage.assign(sBuffer);
@@ -237,13 +233,13 @@ XalanMessageLoader::getMessage(
const char* repText3,
const char* repText4)
{
- XalanDOMChar sBuffer[MAX_MESSAGE_LEN];
+ XalanDOMChar sBuffer[kMaxMessageLength + 1];
s_msgLoader->load(
msgToLoad,
theResultMessage.getMemoryManager(),
sBuffer,
- MAX_MESSAGE_LEN,
+ kMaxMessageLength,
repText1,
repText2,
repText3,
@@ -265,13 +261,13 @@ XalanMessageLoader::getMessage(
const XalanDOMChar* repText3,
const XalanDOMChar* repText4)
{
- XalanDOMChar sBuffer[MAX_MESSAGE_LEN];
+ XalanDOMChar sBuffer[kMaxMessageLength + 1];
s_msgLoader->load(
msgToLoad,
theResultMessage.getMemoryManager(),
sBuffer,
- MAX_MESSAGE_LEN,
+ kMaxMessageLength,
repText1,
repText2,
repText3,

0 comments on commit cab8516

Please sign in to comment.