summaryrefslogtreecommitdiff
path: root/indra/llimage/llpngwrapper.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2017-08-31 16:48:49 +0100
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2017-08-31 16:48:49 +0100
commit57bb63bafd2adc744ea8cab63593abd90c7199df (patch)
tree94ec221ca06ce32dee7e6138d655d8a575a46a23 /indra/llimage/llpngwrapper.cpp
parent936ccff59f2045f5747a0730570784608f39a7b4 (diff)
parent218584593a7815f7494be58a7b36774c47fd047f (diff)
merge
Diffstat (limited to 'indra/llimage/llpngwrapper.cpp')
-rw-r--r--indra/llimage/llpngwrapper.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/indra/llimage/llpngwrapper.cpp b/indra/llimage/llpngwrapper.cpp
index da289ea889..eb70b78a36 100644
--- a/indra/llimage/llpngwrapper.cpp
+++ b/indra/llimage/llpngwrapper.cpp
@@ -112,6 +112,11 @@ void LLPngWrapper::readDataCallback(png_structp png_ptr, png_bytep dest, png_siz
void LLPngWrapper::writeDataCallback(png_structp png_ptr, png_bytep src, png_size_t length)
{
PngDataInfo *dataInfo = (PngDataInfo *) png_get_io_ptr(png_ptr);
+ if (dataInfo->mOffset + length > dataInfo->mDataSize)
+ {
+ png_error(png_ptr, "Data write error. Requested data size exceeds available data size.");
+ return;
+ }
U8 *dest = &dataInfo->mData[dataInfo->mOffset];
memcpy(dest, src, length);
dataInfo->mOffset += static_cast<U32>(length);
@@ -272,7 +277,7 @@ void LLPngWrapper::updateMetaData()
// Method to write raw image into PNG at dest. The raw scanline begins
// at the bottom of the image per SecondLife conventions.
-BOOL LLPngWrapper::writePng(const LLImageRaw* rawImage, U8* dest)
+BOOL LLPngWrapper::writePng(const LLImageRaw* rawImage, U8* dest, size_t destSize)
{
try
{
@@ -313,6 +318,7 @@ BOOL LLPngWrapper::writePng(const LLImageRaw* rawImage, U8* dest)
PngDataInfo dataPtr;
dataPtr.mData = dest;
dataPtr.mOffset = 0;
+ dataPtr.mDataSize = destSize;
png_set_write_fn(mWritePngPtr, &dataPtr, &writeDataCallback, &writeFlush);
// Setup image params