Blame SOURCES/libwmf-0.2.8.4-CVE-2007-3472.patch
|
|
6ccfd1 |
--- libwmf-0.2.8.4/src/extra/gd/gd.c
|
|
|
6ccfd1 |
+++ libwmf-0.2.8.4/src/extra/gd/gd.c
|
|
|
6ccfd1 |
@@ -106,6 +106,18 @@
|
|
|
6ccfd1 |
gdImagePtr im;
|
|
|
6ccfd1 |
unsigned long cpa_size;
|
|
|
6ccfd1 |
|
|
|
6ccfd1 |
+ if (overflow2(sx, sy)) {
|
|
|
6ccfd1 |
+ return NULL;
|
|
|
6ccfd1 |
+ }
|
|
|
6ccfd1 |
+
|
|
|
6ccfd1 |
+ if (overflow2(sizeof (int *), sy)) {
|
|
|
6ccfd1 |
+ return NULL;
|
|
|
6ccfd1 |
+ }
|
|
|
6ccfd1 |
+
|
|
|
6ccfd1 |
+ if (overflow2(sizeof(int), sx)) {
|
|
|
6ccfd1 |
+ return NULL;
|
|
|
6ccfd1 |
+ }
|
|
|
6ccfd1 |
+
|
|
|
6ccfd1 |
im = (gdImage *) gdMalloc (sizeof (gdImage));
|
|
|
6ccfd1 |
if (im == 0) return 0;
|
|
|
6ccfd1 |
memset (im, 0, sizeof (gdImage));
|
|
|
6ccfd1 |
--- libwmf-0.2.8.4/src/extra/gd/gdhelpers.c 2010-12-06 11:47:31.000000000 +0000
|
|
|
6ccfd1 |
+++ libwmf-0.2.8.4/src/extra/gd/gdhelpers.c 2010-12-06 11:48:04.000000000 +0000
|
|
|
6ccfd1 |
@@ -2,6 +2,7 @@
|
|
|
6ccfd1 |
#include "gdhelpers.h"
|
|
|
6ccfd1 |
#include <stdlib.h>
|
|
|
6ccfd1 |
#include <string.h>
|
|
|
6ccfd1 |
+#include <limits.h>
|
|
|
6ccfd1 |
|
|
|
6ccfd1 |
/* TBB: gd_strtok_r is not portable; provide an implementation */
|
|
|
6ccfd1 |
|
|
|
6ccfd1 |
@@ -94,3 +95,18 @@
|
|
|
6ccfd1 |
{
|
|
|
6ccfd1 |
free (ptr);
|
|
|
6ccfd1 |
}
|
|
|
6ccfd1 |
+
|
|
|
6ccfd1 |
+int overflow2(int a, int b)
|
|
|
6ccfd1 |
+{
|
|
|
6ccfd1 |
+ if(a < 0 || b < 0) {
|
|
|
6ccfd1 |
+ fprintf(stderr, "gd warning: one parameter to a memory allocation multiplication is negative, failing operation gracefully\n");
|
|
|
6ccfd1 |
+ return 1;
|
|
|
6ccfd1 |
+ }
|
|
|
6ccfd1 |
+ if(b == 0)
|
|
|
6ccfd1 |
+ return 0;
|
|
|
6ccfd1 |
+ if(a > INT_MAX / b) {
|
|
|
6ccfd1 |
+ fprintf(stderr, "gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n");
|
|
|
6ccfd1 |
+ return 1;
|
|
|
6ccfd1 |
+ }
|
|
|
6ccfd1 |
+ return 0;
|
|
|
6ccfd1 |
+}
|
|
|
6ccfd1 |
--- libwmf-0.2.8.4/src/extra/gd/gdhelpers.h 2010-12-06 11:47:17.000000000 +0000
|
|
|
6ccfd1 |
+++ libwmf-0.2.8.4/src/extra/gd/gdhelpers.h 2010-12-06 11:48:36.000000000 +0000
|
|
|
6ccfd1 |
@@ -15,6 +15,8 @@
|
|
|
6ccfd1 |
void *gdMalloc(size_t size);
|
|
|
6ccfd1 |
void *gdRealloc(void *ptr, size_t size);
|
|
|
6ccfd1 |
|
|
|
6ccfd1 |
+int overflow2(int a, int b);
|
|
|
6ccfd1 |
+
|
|
|
6ccfd1 |
#pragma GCC visibility pop
|
|
|
6ccfd1 |
|
|
|
6ccfd1 |
#endif /* GDHELPERS_H */
|