Repository :
http://git.fedorahosted.org/git/?p=conga-luci-1stgen.git
On branch : RHEL5-active
---------------------------------------------------------------
commit 0e87f04db5ec9f3f52286dd3730722ba4bddff88
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Tue May 21 13:49:01 2013 -0400
ricci: Fix for stack overflow caused by very large cluster.conf files
Fix for a crash that occurs when reading very large cluster.conf files.
Fix by Jan Pokorny <jpokorny(a)redhat.com>
Resolves: rhbz#965785
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---------------------------------------------------------------
ricci/common/File.cpp | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/ricci/common/File.cpp b/ricci/common/File.cpp
index 1099250..c004dd5 100644
--- a/ricci/common/File.cpp
+++ b/ricci/common/File.cpp
@@ -138,18 +138,28 @@ File::read() const
{
MutexLocker l(*_mutex);
+ char *buff = NULL;
long len = size();
- char buff[len];
+
try {
+ buff = new char[len];
+
((fstream *) _pimpl->fs)->seekg(0, ios::beg);
- check_failed();
((fstream *) _pimpl->fs)->read(buff, len);
check_failed();
+ if (len != ((fstream *) _pimpl->fs)->gcount())
+ throw String("Read size mismatch: ") + _path;
String ret(buff, len);
+
::shred(buff, len);
+ delete[] buff;
+
return ret;
} catch ( ... ) {
- ::shred(buff, len);
+ if (buff) {
+ ::shred(buff, len);
+ delete[] buff;
+ }
throw;
}
}