MAINT-3562 FIXED Viewer crashes when updating local textures using Substance Designer : add code for control input buffer size
3e69e78acb
This commit is contained in:
@@ -67,7 +67,7 @@ BOOL LLImagePNG::updateData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
LLPngWrapper::ImageInfo infop;
|
LLPngWrapper::ImageInfo infop;
|
||||||
if (! pngWrapper.readPng(getData(), NULL, &infop))
|
if (! pngWrapper.readPng(getData(), getDataSize(), &infop))
|
||||||
{
|
{
|
||||||
setLastError(pngWrapper.getErrorMessage());
|
setLastError(pngWrapper.getErrorMessage());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -102,7 +102,7 @@ BOOL LLImagePNG::decode(LLImageRaw* raw_image, F32 decode_time)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! pngWrapper.readPng(getData(), raw_image))
|
if (! pngWrapper.readPng(getData(), getDataSize(), raw_image))
|
||||||
{
|
{
|
||||||
setLastError(pngWrapper.getErrorMessage());
|
setLastError(pngWrapper.getErrorMessage());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|||||||
@@ -93,6 +93,12 @@ void LLPngWrapper::errorHandler(png_structp png_ptr, png_const_charp msg)
|
|||||||
void LLPngWrapper::readDataCallback(png_structp png_ptr, png_bytep dest, png_size_t length)
|
void LLPngWrapper::readDataCallback(png_structp png_ptr, png_bytep dest, png_size_t length)
|
||||||
{
|
{
|
||||||
PngDataInfo *dataInfo = (PngDataInfo *) png_get_io_ptr(png_ptr);
|
PngDataInfo *dataInfo = (PngDataInfo *) png_get_io_ptr(png_ptr);
|
||||||
|
if (dataInfo->mOffset + length > dataInfo->mDataSize)
|
||||||
|
{
|
||||||
|
png_error(png_ptr, "Data read error. Requested data size exceeds available data size.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
U8 *src = &dataInfo->mData[dataInfo->mOffset];
|
U8 *src = &dataInfo->mData[dataInfo->mOffset];
|
||||||
memcpy(dest, src, length);
|
memcpy(dest, src, length);
|
||||||
dataInfo->mOffset += static_cast<U32>(length);
|
dataInfo->mOffset += static_cast<U32>(length);
|
||||||
@@ -120,7 +126,7 @@ void LLPngWrapper::writeFlush(png_structp png_ptr)
|
|||||||
// The scanline also begins at the bottom of
|
// The scanline also begins at the bottom of
|
||||||
// the image (per SecondLife conventions) instead of at the top, so we
|
// the image (per SecondLife conventions) instead of at the top, so we
|
||||||
// must assign row-pointers in "reverse" order.
|
// must assign row-pointers in "reverse" order.
|
||||||
BOOL LLPngWrapper::readPng(U8* src, LLImageRaw* rawImage, ImageInfo *infop)
|
BOOL LLPngWrapper::readPng(U8* src, S32 dataSize, LLImageRaw* rawImage, ImageInfo *infop)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -139,6 +145,7 @@ BOOL LLPngWrapper::readPng(U8* src, LLImageRaw* rawImage, ImageInfo *infop)
|
|||||||
PngDataInfo dataPtr;
|
PngDataInfo dataPtr;
|
||||||
dataPtr.mData = src;
|
dataPtr.mData = src;
|
||||||
dataPtr.mOffset = 0;
|
dataPtr.mOffset = 0;
|
||||||
|
dataPtr.mDataSize = dataSize;
|
||||||
|
|
||||||
png_set_read_fn(mReadPngPtr, &dataPtr, &readDataCallback);
|
png_set_read_fn(mReadPngPtr, &dataPtr, &readDataCallback);
|
||||||
png_set_sig_bytes(mReadPngPtr, 0);
|
png_set_sig_bytes(mReadPngPtr, 0);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
BOOL isValidPng(U8* src);
|
BOOL isValidPng(U8* src);
|
||||||
BOOL readPng(U8* src, LLImageRaw* rawImage, ImageInfo *infop = NULL);
|
BOOL readPng(U8* src, S32 dataSize, LLImageRaw* rawImage, ImageInfo *infop = NULL);
|
||||||
BOOL writePng(const LLImageRaw* rawImage, U8* dst);
|
BOOL writePng(const LLImageRaw* rawImage, U8* dst);
|
||||||
U32 getFinalSize();
|
U32 getFinalSize();
|
||||||
const std::string& getErrorMessage();
|
const std::string& getErrorMessage();
|
||||||
@@ -66,6 +66,7 @@ private:
|
|||||||
{
|
{
|
||||||
U8 *mData;
|
U8 *mData;
|
||||||
U32 mOffset;
|
U32 mOffset;
|
||||||
|
S32 mDataSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void writeFlush(png_structp png_ptr);
|
static void writeFlush(png_structp png_ptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user