Fixed buffer overflow when saving certain images in the Windows icon format.
When an image did not have a width with a multiple of 4 the calculations for the number of padding bytes (to get a scan line DWORD aligned) would be wrong. This caused a buffer overrun when saving the 1 bits per pixel mask. Fixes #12937. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67296 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -75,6 +75,7 @@ private:
|
||||
CPPUNIT_TEST( SaveAnimatedGIF );
|
||||
CPPUNIT_TEST( ReadCorruptedTGA );
|
||||
CPPUNIT_TEST( GIFComment );
|
||||
CPPUNIT_TEST( DibPadding );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void LoadFromSocketStream();
|
||||
@@ -87,6 +88,7 @@ private:
|
||||
void SaveAnimatedGIF();
|
||||
void ReadCorruptedTGA();
|
||||
void GIFComment();
|
||||
void DibPadding();
|
||||
|
||||
DECLARE_NO_COPY_CLASS(ImageTestCase)
|
||||
};
|
||||
@@ -900,6 +902,7 @@ void CompareImage(const wxImageHandler& handler, const wxImage& image,
|
||||
if ( testPalette
|
||||
&& ( !(type == wxBITMAP_TYPE_BMP
|
||||
|| type == wxBITMAP_TYPE_GIF
|
||||
|| type == wxBITMAP_TYPE_ICO
|
||||
|| type == wxBITMAP_TYPE_PNG)
|
||||
|| type == wxBITMAP_TYPE_XPM) )
|
||||
{
|
||||
@@ -1251,6 +1254,23 @@ void ImageTestCase::GIFComment()
|
||||
}
|
||||
}
|
||||
|
||||
void ImageTestCase::DibPadding()
|
||||
{
|
||||
/*
|
||||
There used to be an error with calculating the DWORD aligned scan line
|
||||
pitch for a BMP/ICO resulting in buffer overwrites (with at least MSVC9
|
||||
Debug this gave a heap corruption assertion when saving the mask of
|
||||
an ICO). Test for it here.
|
||||
*/
|
||||
wxImage image("horse.gif");
|
||||
CPPUNIT_ASSERT( image.IsOk() );
|
||||
|
||||
image = image.Scale(99, 99);
|
||||
|
||||
CompareImage(*wxImage::FindHandler(wxBITMAP_TYPE_ICO),
|
||||
image, wxIMAGE_HAVE_PALETTE);
|
||||
}
|
||||
|
||||
#endif //wxUSE_IMAGE
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user