~ubuntu-branches/ubuntu/maverick/libgd2/maverick

« back to all changes in this revision

Viewing changes to debian/patches/01_CAN-2004-0941.patch

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2006-05-21 09:51:07 UTC
  • Revision ID: james.westby@ubuntu.com-20060521095107-ky3agku6ls9gl158
Tags: 2.0.33-4
* Have libgd-noxpm-dev provide libgd2-dev (a virtual package since
  woody). libgd-xpm-dev does not provide it, as the two packages does
  not provide same shlibdeps info: Both provide same ABI but not same
  package dependencies, so those requiring XPM support will want to
  explicitly (build-)depend on that variant. Closes: bug#350704,
  #358306 (thanks to Daniel Schepler <schepler@math.berkeley.edu> and
  Martin Michlmayr <tbm@cyrius.com> for reporting, and to Junichi
  Uekawa <dancer@netfort.gr.jp> for patience and helpful input).
* Use quilt (instead of CDBS builtin patch routines).
* Use local cdbs snippet to enable debian-control (semi-)auto-update.
* Update local cdbs snippet buildinfo.mk:
  + Correct namespace.
* Update local cdbs snippet copyright-check.mk:
  + Correct namespace.
  + Treat all found files as non-binary.
  + Broaden scan to also look for "(c)" by default.
  + Make egrep options configurable.
* Semi-auto-update debian/control (nothing remarkable).
* Semi-auto-update debian/copyright_hints (nothing remarkable).
* Renumber and unfuzz patches, and add debian/patches/README
  documenting the new numbering scheme.
* Add patch 1003 fixing an antialiasing segfault. Closes: bug#364024
  (thanks to Paul <elegant_dice@yahoo.com>).
* Add patch 1004 improving antialiasing lines at image edges (thanks
  to Paul <elegant_dice@yahoo.com>).
* Add patch 1005 to more sanely bail out on missing or wrong data, and
  include config.h also for tools and examples. This closes:
  bug#360966 (thanks to the Graphviz project were these was extracted
  from, and to Matthias Klose <doko@cs.tu-berlin.de> reporting it).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
diff -ruN libgd2-2.0.33/gd.c libgd2-2.0.33.nmu/gd.c
2
 
--- libgd2-2.0.33/gd.c  2004-11-01 19:28:56.000000000 +0100
3
 
+++ libgd2-2.0.33.nmu/gd.c      2005-02-25 19:49:44.000000000 +0100
4
 
@@ -7,6 +7,7 @@
5
 
 #include <string.h>
6
 
 #include <stdlib.h>
7
 
 /* 2.03: don't include zlib here or we can't build without PNG */
8
 
+#include <limits.h>
9
 
 #include "gd.h"
10
 
 #include "gdhelpers.h"
11
 
 
12
 
@@ -74,7 +75,11 @@
13
 
   im = (gdImage *) gdMalloc (sizeof (gdImage));
14
 
   memset (im, 0, sizeof (gdImage));
15
 
   /* Row-major ever since gd 1.3 */
16
 
-  im->pixels = (unsigned char **) gdMalloc (sizeof (unsigned char *) * sy);
17
 
+  if (sy >= INT_MAX/sizeof (unsigned char *) ||
18
 
+      (im->pixels = (unsigned char **) gdMalloc (sizeof (unsigned char *) * sy)) == NULL) {
19
 
+    gdFree(im);
20
 
+    return NULL;
21
 
+  }
22
 
   im->polyInts = 0;
23
 
   im->polyAllocated = 0;
24
 
   im->brush = 0;
25
 
@@ -2462,6 +2467,8 @@
26
 
     }
27
 
   bytes = (w * h / 8) + 1;
28
 
   im = gdImageCreate (w, h);
29
 
+  if (!im)
30
 
+    return 0;
31
 
   gdImageColorAllocate (im, 255, 255, 255);
32
 
   gdImageColorAllocate (im, 0, 0, 0);
33
 
   x = 0;
34
 
@@ -2600,6 +2607,8 @@
35
 
        {
36
 
          im->polyAllocated *= 2;
37
 
        }
38
 
+      if (im->polyAllocated >= INT_MAX/sizeof (int))
39
 
+       return;
40
 
       im->polyInts = (int *) gdRealloc (im->polyInts,
41
 
                                        sizeof (int) * im->polyAllocated);
42
 
     }
43
 
diff -ruN libgd2-2.0.33/gd_gd.c libgd2-2.0.33.nmu/gd_gd.c
44
 
--- libgd2-2.0.33/gd_gd.c       2004-10-27 16:22:04.000000000 +0200
45
 
+++ libgd2-2.0.33.nmu/gd_gd.c   2005-02-25 19:49:44.000000000 +0100
46
 
@@ -149,6 +149,10 @@
47
 
     {
48
 
       im = gdImageCreate (*sx, *sy);
49
 
     }
50
 
+
51
 
+  if (!im)
52
 
+    goto fail1;
53
 
+
54
 
   if (!_gdGetColors (in, im, gd2xFlag))
55
 
     {
56
 
       goto fail2;
57
 
diff -ruN libgd2-2.0.33/gd_io_dp.c libgd2-2.0.33.nmu/gd_io_dp.c
58
 
--- libgd2-2.0.33/gd_io_dp.c    2004-10-28 20:05:17.000000000 +0200
59
 
+++ libgd2-2.0.33.nmu/gd_io_dp.c        2005-02-25 19:49:44.000000000 +0100
60
 
@@ -23,6 +23,7 @@
61
 
 #include <math.h>
62
 
 #include <string.h>
63
 
 #include <stdlib.h>
64
 
+#include <limits.h>
65
 
 #include "gd.h"
66
 
 #include "gdhelpers.h"
67
 
 
68
 
@@ -202,7 +203,8 @@
69
 
       if (overflow2(dp->realSize, 2)) {
70
 
         return FALSE;
71
 
       }
72
 
-      if (!gdReallocDynamic (dp, dp->realSize * 2))
73
 
+      if (bytesNeeded >= INT_MAX/2 ||
74
 
+         !gdReallocDynamic (dp, bytesNeeded * 2))
75
 
        {
76
 
          dp->dataGood = FALSE;
77
 
          return FALSE;
78
 
diff -ruN libgd2-2.0.33/gd_png.c libgd2-2.0.33.nmu/gd_png.c
79
 
--- libgd2-2.0.33/gd_png.c      2004-10-28 20:09:52.000000000 +0200
80
 
+++ libgd2-2.0.33.nmu/gd_png.c  2005-02-25 19:49:44.000000000 +0100
81
 
@@ -6,6 +6,8 @@
82
 
 #include <math.h>
83
 
 #include <string.h>
84
 
 #include <stdlib.h>
85
 
+#include <limits.h>
86
 
+
87
 
 #include "gd.h"
88
 
 
89
 
 /* JCE: Arrange HAVE_LIBPNG so that it can be set in gd.h */
90
 
@@ -188,6 +190,9 @@
91
 
 
92
 
   png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
93
 
                &interlace_type, NULL, NULL);
94
 
+  if (width >= INT_MAX/sizeof (int) ||
95
 
+      width*sizeof (int) >= INT_MAX/height)
96
 
+    return NULL;
97
 
   if ((color_type == PNG_COLOR_TYPE_RGB) ||
98
 
       (color_type == PNG_COLOR_TYPE_RGB_ALPHA))
99
 
     {
100
 
diff -ruN libgd2-2.0.33/gdxpm.c libgd2-2.0.33.nmu/gdxpm.c
101
 
--- libgd2-2.0.33/gdxpm.c       2004-10-28 18:54:24.000000000 +0200
102
 
+++ libgd2-2.0.33.nmu/gdxpm.c   2005-02-25 19:49:44.000000000 +0100
103
 
@@ -12,6 +12,7 @@
104
 
 
105
 
 #include <stdio.h>
106
 
 #include <stdlib.h>
107
 
+#include <limits.h>
108
 
 #include <string.h>
109
 
 #include "gd.h"
110
 
 #include "gdhelpers.h"
111
 
@@ -47,6 +48,10 @@
112
 
     return 0;
113
 
 
114
 
   number = image.ncolors;
115
 
+
116
 
+  if (number >= INT_MAX/sizeof (int))
117
 
+    return (0);
118
 
+
119
 
   colors = (int *) gdMalloc (sizeof (int) * number);
120
 
   if (colors == NULL)
121
 
     return (0);
122
 
diff -ruN libgd2-2.0.33/wbmp.c libgd2-2.0.33.nmu/wbmp.c
123
 
--- libgd2-2.0.33/wbmp.c        2004-10-28 20:13:31.000000000 +0200
124
 
+++ libgd2-2.0.33.nmu/wbmp.c    2005-02-25 19:49:44.000000000 +0100
125
 
@@ -17,6 +17,7 @@
126
 
 #include <stddef.h>
127
 
 #include <stdlib.h>
128
 
 #include <string.h>
129
 
+#include <limits.h>
130
 
 
131
 
 #include "wbmp.h"
132
 
 #include "gd.h"
133
 
@@ -127,8 +128,10 @@
134
 
     gdFree(wbmp);
135
 
     return NULL;
136
 
   }
137
 
-  if ((wbmp->bitmap =
138
 
-       (int *) gdMalloc (sizeof (int) * width * height)) == NULL)
139
 
+
140
 
+  if (width >= INT_MAX/sizeof(int) ||
141
 
+      width*sizeof(int) >= INT_MAX/height ||
142
 
+      (wbmp->bitmap = (int *) gdMalloc (sizeof (int) * width * height)) == NULL)
143
 
     {
144
 
       gdFree (wbmp);
145
 
       return (NULL);
146
 
@@ -194,8 +197,9 @@
147
 
       gdFree(wbmp);
148
 
       return (-1);
149
 
     }
150
 
-  if ((wbmp->bitmap =
151
 
-       (int *) gdMalloc (sizeof (int) * wbmp->width * wbmp->height)) == NULL)
152
 
+  if (wbmp->width >= INT_MAX/sizeof(int) ||
153
 
+      wbmp->width*sizeof(int) >= INT_MAX/wbmp->height ||
154
 
+      (wbmp->bitmap = (int *) gdMalloc (sizeof (int) * wbmp->width * wbmp->height)) == NULL)
155
 
     {
156
 
       gdFree (wbmp);
157
 
       return (-1);