1 --- libwmf-0.2.8.4/src/extra/gd/gd.c
2 +++ libwmf-0.2.8.4/src/extra/gd/gd.c
5 unsigned long cpa_size;
7 + if (overflow2(sx, sy)) {
11 + if (overflow2(sizeof (int *), sy)) {
15 + if (overflow2(sizeof(int), sx)) {
19 im = (gdImage *) gdMalloc (sizeof (gdImage));
20 if (im == 0) return 0;
21 memset (im, 0, sizeof (gdImage));
22 --- libwmf-0.2.8.4/src/extra/gd/gdhelpers.c 2010-12-06 11:47:31.000000000 +0000
23 +++ libwmf-0.2.8.4/src/extra/gd/gdhelpers.c 2010-12-06 11:48:04.000000000 +0000
25 #include "gdhelpers.h"
30 /* TBB: gd_strtok_r is not portable; provide an implementation */
37 +int overflow2(int a, int b)
39 + if(a < 0 || b < 0) {
40 + fprintf(stderr, "gd warning: one parameter to a memory allocation multiplication is negative, failing operation gracefully\n");
45 + if(a > INT_MAX / b) {
46 + fprintf(stderr, "gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n");
51 --- libwmf-0.2.8.4/src/extra/gd/gdhelpers.h 2010-12-06 11:47:17.000000000 +0000
52 +++ libwmf-0.2.8.4/src/extra/gd/gdhelpers.h 2010-12-06 11:48:36.000000000 +0000
54 void *gdMalloc(size_t size);
55 void *gdRealloc(void *ptr, size_t size);
57 +int overflow2(int a, int b);
59 #endif /* GDHELPERS_H */