1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
diff -Nurad imlib2-1.4.1/src/modules/loaders/loader_argb.c imlib2-1.4.2/src/modules/loaders/loader_argb.c
--- imlib2-1.4.1/src/modules/loaders/loader_argb.c 2007-04-09 14:55:29.000000000 +0200
+++ imlib2-1.4.2/src/modules/loaders/loader_argb.c 2008-08-17 11:39:13.000000000 +0200
@@ -10,7 +10,7 @@
load(ImlibImage * im, ImlibProgressFunction progress,
char progress_granularity, char immediate_load)
{
- int w, h, alpha;
+ int w = 0, h = 0, alpha = 0;
FILE *f;
if (im->data)
@@ -23,11 +23,13 @@
{
char buf[256], buf2[256];
+ buf[0] = '\0';
if (!fgets(buf, 255, f))
{
fclose(f);
return 0;
}
+ buf2[0] = '\0';
sscanf(buf, "%s %i %i %i", buf2, &w, &h, &alpha);
if (strcmp(buf2, "ARGB"))
{
diff -Nurad imlib2-1.4.1/src/modules/loaders/loader_bmp.c imlib2-1.4.2/src/modules/loaders/loader_bmp.c
--- imlib2-1.4.1/src/modules/loaders/loader_bmp.c 2007-11-05 09:02:28.000000000 +0100
+++ imlib2-1.4.2/src/modules/loaders/loader_bmp.c 2008-08-17 11:39:13.000000000 +0200
@@ -565,7 +565,7 @@
unsigned char *buffer_end_minus_1 = buffer_end - 1;
x = 0;
y = 0;
- for (i = 0; i < imgsize && buffer_ptr < buffer_end_minus_1 && g; i++)
+ for (i = 0; i < imgsize && buffer_ptr < buffer_end_minus_1; i++)
{
byte1 = buffer_ptr[0];
byte2 = buffer_ptr[1];
diff -Nurad imlib2-1.4.1/src/modules/loaders/loader_jpeg.c imlib2-1.4.2/src/modules/loaders/loader_jpeg.c
--- imlib2-1.4.1/src/modules/loaders/loader_jpeg.c 2007-04-09 14:55:29.000000000 +0200
+++ imlib2-1.4.2/src/modules/loaders/loader_jpeg.c 2008-10-21 04:32:51.000000000 +0200
@@ -78,6 +78,7 @@
im->h = h = cinfo.output_height;
if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
{
+ im->w = im->h = 0;
jpeg_destroy_decompress(&cinfo);
fclose(f);
return 0;
@@ -94,15 +95,18 @@
im->w = w = cinfo.output_width;
im->h = h = cinfo.output_height;
- if (cinfo.rec_outbuf_height > 16)
+ if ((cinfo.rec_outbuf_height > 16) || (cinfo.output_components <= 0) ||
+ (w < 1) || (h < 1) || (w > 8192) || (h > 8192))
{
+ im->w = im->h = 0;
jpeg_destroy_decompress(&cinfo);
fclose(f);
return 0;
}
- data = malloc(w * 16 * 3);
+ data = malloc(w * 16 * cinfo.output_components);
if (!data)
{
+ im->w = im->h = 0;
jpeg_destroy_decompress(&cinfo);
fclose(f);
return 0;
@@ -111,6 +115,7 @@
ptr2 = im->data = malloc(w * h * sizeof(DATA32));
if (!im->data)
{
+ im->w = im->h = 0;
free(data);
jpeg_destroy_decompress(&cinfo);
fclose(f);
@@ -118,10 +123,10 @@
}
count = 0;
prevy = 0;
- if (cinfo.output_components == 3)
+ if (cinfo.output_components > 1)
{
for (i = 0; i < cinfo.rec_outbuf_height; i++)
- line[i] = data + (i * w * 3);
+ line[i] = data + (i * w * cinfo.output_components);
for (l = 0; l < h; l += cinfo.rec_outbuf_height)
{
jpeg_read_scanlines(&cinfo, line, cinfo.rec_outbuf_height);
@@ -137,7 +142,7 @@
(0xff000000) | ((ptr[0]) << 16) | ((ptr[1]) <<
8) |
(ptr[2]);
- ptr += 3;
+ ptr += cinfo.output_components;
ptr2++;
}
}
diff -Nurad imlib2-1.4.1/src/modules/loaders/loader_lbm.c imlib2-1.4.2/src/modules/loaders/loader_lbm.c
--- imlib2-1.4.1/src/modules/loaders/loader_lbm.c 2007-04-09 14:55:29.000000000 +0200
+++ imlib2-1.4.2/src/modules/loaders/loader_lbm.c 2008-08-17 11:39:13.000000000 +0200
@@ -437,6 +437,7 @@
}
}
if (!full || !ok) {
+ im->w = im->h = 0;
freeilbm(&ilbm);
return ok;
}
@@ -452,11 +453,10 @@
plane[0] = NULL;
im->data = malloc(im->w * im->h * sizeof(DATA32));
- if (im->data) {
- n = ilbm.depth;
- if (ilbm.mask == 1) n++;
-
- plane[0] = malloc(((im->w + 15) / 16) * 2 * n);
+ n = ilbm.depth;
+ if (ilbm.mask == 1) n++;
+ plane[0] = malloc(((im->w + 15) / 16) * 2 * n);
+ if (im->data && plane[0]) {
for (i = 1; i < n; i++) plane[i] = plane[i - 1] + ((im->w + 15) / 16) * 2;
z = ((im->w + 15) / 16) * 2 * n;
@@ -492,9 +492,10 @@
/*----------
* We either had a successful decode, the user cancelled, or we couldn't get
- * the memory for im->data.
+ * the memory for im->data or plane[0].
*----------*/
if (!ok) {
+ im->w = im->h = 0;
if (im->data) free(im->data);
im->data = NULL;
}
diff -Nurad imlib2-1.4.1/src/modules/loaders/loader_pnm.c imlib2-1.4.2/src/modules/loaders/loader_pnm.c
--- imlib2-1.4.1/src/modules/loaders/loader_pnm.c 2008-06-06 05:42:29.000000000 +0200
+++ imlib2-1.4.2/src/modules/loaders/loader_pnm.c 2008-10-21 04:32:51.000000000 +0200
@@ -348,7 +348,7 @@
for (x = 0; x < w; x++)
{
*ptr2 =
- 0xff000000 | (((ptr[0] * 255) / v) << 16) |
+ 0xff000000 | (((iptr[0] * 255) / v) << 16) |
(((iptr[1] * 255) / v) << 8) | ((iptr[2] *
255) / v);
ptr2++;
diff -Nurad imlib2-1.4.1/src/modules/loaders/loader_tga.c imlib2-1.4.2/src/modules/loaders/loader_tga.c
--- imlib2-1.4.1/src/modules/loaders/loader_tga.c 2007-04-09 14:55:29.000000000 +0200
+++ imlib2-1.4.2/src/modules/loaders/loader_tga.c 2008-08-17 11:39:13.000000000 +0200
@@ -350,7 +350,9 @@
else
dataptr = im->data + (y * im->w);
- for (x = 0; x < im->w; x++) /* for each pixel in the row */
+ for (x = 0;
+ (x < im->w) && (bufptr + bpp / 8 <= bufend);
+ x++) /* for each pixel in the row */
{
switch (bpp)
{
@@ -406,7 +408,7 @@
/* loop until we've got all the pixels or run out of input */
while ((dataptr < final_pixel) &&
- ((bufptr + 1 + (bpp / 8)) < bufend))
+ ((bufptr + 1 + (bpp / 8)) <= bufend))
{
int count;
diff -Nurad imlib2-1.4.1/src/modules/loaders/loader_xpm.c imlib2-1.4.2/src/modules/loaders/loader_xpm.c
--- imlib2-1.4.1/src/modules/loaders/loader_xpm.c 2008-06-06 05:42:29.000000000 +0200
+++ imlib2-1.4.2/src/modules/loaders/loader_xpm.c 2008-10-21 04:32:51.000000000 +0200
@@ -97,7 +99,7 @@
int pc, c, i, j, k, w, h, ncolors, cpp, comment, transp,
quote, context, len, done, r, g, b, backslash;
- char *line, s[256], tok[128], col[256];
+ char *line, s[256], tok[256], col[256];
int lsz = 256;
struct _cmap {
unsigned char str[6];
@@ -151,6 +153,9 @@
pixels = 0;
count = 0;
line = malloc(lsz);
+ if (!line)
+ return 0;
+
backslash = 0;
memset(lookup, 0, sizeof(lookup));
while (!done)
|