tog-pegasus/pegasus-2.5.1-obz4956.patch

93 lines
2.7 KiB
Diff
Raw Normal View History

--- pegasus/src/Pegasus/Common/HTTPConnection.cpp.obz4956 2006-05-02 14:27:39.000000000 -0400
+++ pegasus/src/Pegasus/Common/HTTPConnection.cpp 2006-05-02 15:09:56.000000000 -0400
@@ -1036,10 +1036,20 @@
// reserve space for entire non-chunked message
if (_contentLength > 0)
{
- Uint32 capacity = (Uint32)(_contentLength + _contentOffset + 1);
- _incomingBuffer.reserveCapacity(capacity);
- data = (char *)_incomingBuffer.getData();
- data[capacity-1] = 0;
+ try
+ {
+ Uint32 capacity = (Uint32)(_contentLength + _contentOffset + 1);
+ _incomingBuffer.reserveCapacity(capacity);
+ data = (char *)_incomingBuffer.getData();
+ data[capacity-1] = 0;
+ }catch(const PEGASUS_STD(bad_alloc)&)
+ {
+ _throwEventFailure(HTTP_STATUS_REQUEST_TOO_LARGE,
+ "Error reserving space for non-chunked message");
+ }catch(...)
+ {
+ _throwEventFailure(httpStatusInternal, "unexpected exception");
+ }
}
break;
--- pegasus/src/Pegasus/Common/String.cpp.obz4956 2006-05-02 14:27:39.000000000 -0400
+++ pegasus/src/Pegasus/Common/String.cpp 2006-05-02 15:12:59.000000000 -0400
@@ -51,6 +51,10 @@
#include <unicode/uchar.h>
#endif
+#ifndef PEGASUS_CHECK_FOR_OVERFLOW
+#define PEGASUS_CHECK_FOR_OVERFLOW(capacity) { if (capacity > 0x3FFFFFFF) throw PEGASUS_STD(bad_alloc)(); }
+#endif
+
PEGASUS_NAMESPACE_BEGIN
//==============================================================================
@@ -166,8 +170,7 @@
{
#ifndef PEGASUS_STRING_NO_THROW
- if (x > 0x0FFFFFFF)
- throw PEGASUS_STD(bad_alloc)();
+ PEGASUS_CHECK_FOR_OVERFLOW(x);
#endif
@@ -545,9 +548,7 @@
{
#ifndef PEGASUS_STRING_NO_THROW
- // Any string bigger than this is seriously suspect.
- if (cap > 0x0FFFFFFF)
- throw PEGASUS_STD(bad_alloc)();
+ PEGASUS_CHECK_FOR_OVERFLOW(cap);
#endif
--- pegasus/src/Pegasus/Common/Buffer.cpp.obz4956 2006-03-17 13:59:03.000000000 -0500
+++ pegasus/src/Pegasus/Common/Buffer.cpp 2006-05-02 15:06:06.000000000 -0400
@@ -43,11 +43,17 @@
static const size_t MIN_CAPACITY = 2048;
+#ifndef PEGASUS_CHECK_FOR_OVERFLOW
+#define PEGASUS_CHECK_FOR_OVERFLOW(capacity) { if (capacity > 0x3FFFFFFF) throw PEGASUS_STD(bad_alloc)(); }
+#endif
+
static Uint32 _next_pow_2(Uint32 x)
{
if (x < MIN_CAPACITY)
return MIN_CAPACITY;
+ PEGASUS_CHECK_FOR_OVERFLOW(x);
+
x--;
x |= (x >> 1);
x |= (x >> 2);
@@ -132,7 +138,10 @@
_rep->size = 0;
}
else
+ {
+ PEGASUS_CHECK_FOR_OVERFLOW(_rep->cap);
_rep = _reallocate(_rep, _rep->cap ? (2 * _rep->cap) : MIN_CAPACITY);
+ }
}
void Buffer::insert(size_t pos, const char* data, size_t size)