|
|
83bc7c |
--- libwmf-0.2.8.4/src/ipa/ipa/bmp.h 2015-06-08 14:46:24.591876404 +0100
|
|
|
83bc7c |
+++ libwmf-0.2.8.4/src/ipa/ipa/bmp.h 2015-06-08 14:46:35.345993247 +0100
|
|
|
83bc7c |
@@ -859,7 +859,7 @@
|
|
|
83bc7c |
%
|
|
|
83bc7c |
%
|
|
|
83bc7c |
*/
|
|
|
83bc7c |
-static void DecodeImage (wmfAPI* API,wmfBMP* bmp,BMPSource* src,unsigned int compression,unsigned char* pixels)
|
|
|
83bc7c |
+static int DecodeImage (wmfAPI* API,wmfBMP* bmp,BMPSource* src,unsigned int compression,unsigned char* pixels)
|
|
|
83bc7c |
{ int byte;
|
|
|
83bc7c |
int count;
|
|
|
83bc7c |
int i;
|
|
|
83bc7c |
@@ -870,12 +870,14 @@
|
|
|
83bc7c |
U32 u;
|
|
|
83bc7c |
|
|
|
83bc7c |
unsigned char* q;
|
|
|
83bc7c |
+ unsigned char* end;
|
|
|
83bc7c |
|
|
|
83bc7c |
for (u = 0; u < ((U32) bmp->width * (U32) bmp->height); u++) pixels[u] = 0;
|
|
|
83bc7c |
|
|
|
83bc7c |
byte = 0;
|
|
|
83bc7c |
x = 0;
|
|
|
83bc7c |
q = pixels;
|
|
|
83bc7c |
+ end = pixels + bmp->width * bmp->height;
|
|
|
83bc7c |
|
|
|
83bc7c |
for (y = 0; y < bmp->height; )
|
|
|
83bc7c |
{ count = ReadBlobByte (src);
|
|
|
83bc7c |
@@ -884,7 +886,10 @@
|
|
|
83bc7c |
{ /* Encoded mode. */
|
|
|
83bc7c |
byte = ReadBlobByte (src);
|
|
|
83bc7c |
for (i = 0; i < count; i++)
|
|
|
83bc7c |
- { if (compression == 1)
|
|
|
83bc7c |
+ {
|
|
|
83bc7c |
+ if (q == end)
|
|
|
83bc7c |
+ return 0;
|
|
|
83bc7c |
+ if (compression == 1)
|
|
|
83bc7c |
{ (*(q++)) = (unsigned char) byte;
|
|
|
83bc7c |
}
|
|
|
83bc7c |
else
|
|
|
83bc7c |
@@ -896,13 +901,15 @@
|
|
|
83bc7c |
else
|
|
|
83bc7c |
{ /* Escape mode. */
|
|
|
83bc7c |
count = ReadBlobByte (src);
|
|
|
83bc7c |
- if (count == 0x01) return;
|
|
|
83bc7c |
+ if (count == 0x01) return 1;
|
|
|
83bc7c |
switch (count)
|
|
|
83bc7c |
{
|
|
|
83bc7c |
case 0x00:
|
|
|
83bc7c |
{ /* End of line. */
|
|
|
83bc7c |
x = 0;
|
|
|
83bc7c |
y++;
|
|
|
83bc7c |
+ if (y >= bmp->height)
|
|
|
83bc7c |
+ return 0;
|
|
|
83bc7c |
q = pixels + y * bmp->width;
|
|
|
83bc7c |
break;
|
|
|
83bc7c |
}
|
|
|
83bc7c |
@@ -910,13 +917,20 @@
|
|
|
83bc7c |
{ /* Delta mode. */
|
|
|
83bc7c |
x += ReadBlobByte (src);
|
|
|
83bc7c |
y += ReadBlobByte (src);
|
|
|
83bc7c |
+ if (y >= bmp->height)
|
|
|
83bc7c |
+ return 0;
|
|
|
83bc7c |
+ if (x >= bmp->width)
|
|
|
83bc7c |
+ return 0;
|
|
|
83bc7c |
q = pixels + y * bmp->width + x;
|
|
|
83bc7c |
break;
|
|
|
83bc7c |
}
|
|
|
83bc7c |
default:
|
|
|
83bc7c |
{ /* Absolute mode. */
|
|
|
83bc7c |
for (i = 0; i < count; i++)
|
|
|
83bc7c |
- { if (compression == 1)
|
|
|
83bc7c |
+ {
|
|
|
83bc7c |
+ if (q == end)
|
|
|
83bc7c |
+ return 0;
|
|
|
83bc7c |
+ if (compression == 1)
|
|
|
83bc7c |
{ (*(q++)) = ReadBlobByte (src);
|
|
|
83bc7c |
}
|
|
|
83bc7c |
else
|
|
|
83bc7c |
@@ -943,7 +957,7 @@
|
|
|
83bc7c |
byte = ReadBlobByte (src); /* end of line */
|
|
|
83bc7c |
byte = ReadBlobByte (src);
|
|
|
83bc7c |
|
|
|
83bc7c |
- return;
|
|
|
83bc7c |
+ return 1;
|
|
|
83bc7c |
}
|
|
|
83bc7c |
|
|
|
83bc7c |
/*
|
|
|
83bc7c |
@@ -1143,8 +1157,18 @@
|
|
|
83bc7c |
}
|
|
|
83bc7c |
}
|
|
|
83bc7c |
else
|
|
|
83bc7c |
- { /* Convert run-length encoded raster pixels. */
|
|
|
83bc7c |
- DecodeImage (API,bmp,src,(unsigned int) bmp_info.compression,data->image);
|
|
|
83bc7c |
+ {
|
|
|
83bc7c |
+ if (bmp_info.bits_per_pixel == 8) /* Convert run-length encoded raster pixels. */
|
|
|
83bc7c |
+ {
|
|
|
83bc7c |
+ if (!DecodeImage (API,bmp,src,(unsigned int) bmp_info.compression,data->image))
|
|
|
83bc7c |
+ { WMF_ERROR (API,"corrupt bmp");
|
|
|
83bc7c |
+ API->err = wmf_E_BadFormat;
|
|
|
83bc7c |
+ }
|
|
|
83bc7c |
+ }
|
|
|
83bc7c |
+ else
|
|
|
83bc7c |
+ { WMF_ERROR (API,"Unexpected pixel depth");
|
|
|
83bc7c |
+ API->err = wmf_E_BadFormat;
|
|
|
83bc7c |
+ }
|
|
|
83bc7c |
}
|
|
|
83bc7c |
|
|
|
83bc7c |
if (ERR (API))
|
|
|
83bc7c |
--- libwmf-0.2.8.4/src/ipa/ipa.h 2015-06-08 14:46:24.590876393 +0100
|
|
|
83bc7c |
+++ libwmf-0.2.8.4/src/ipa/ipa.h 2015-06-08 14:46:35.345993247 +0100
|
|
|
83bc7c |
@@ -48,7 +48,7 @@
|
|
|
83bc7c |
static unsigned short ReadBlobLSBShort (BMPSource*);
|
|
|
83bc7c |
static unsigned long ReadBlobLSBLong (BMPSource*);
|
|
|
83bc7c |
static long TellBlob (BMPSource*);
|
|
|
83bc7c |
-static void DecodeImage (wmfAPI*,wmfBMP*,BMPSource*,unsigned int,unsigned char*);
|
|
|
83bc7c |
+static int DecodeImage (wmfAPI*,wmfBMP*,BMPSource*,unsigned int,unsigned char*);
|
|
|
83bc7c |
static void ReadBMPImage (wmfAPI*,wmfBMP*,BMPSource*);
|
|
|
83bc7c |
static int ExtractColor (wmfAPI*,wmfBMP*,wmfRGB*,unsigned int,unsigned int);
|
|
|
83bc7c |
static void SetColor (wmfAPI*,wmfBMP*,wmfRGB*,unsigned char,unsigned int,unsigned int);
|