gdk-pixbuf-0.22.0-loaders.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. diff -NurdB gdk-pixbuf-0.22.0/gdk-pixbuf/io-ico.c gdk-pixbuf-0.22.0-patched/gdk-pixbuf/io-ico.c
  2. --- gdk-pixbuf-0.22.0/gdk-pixbuf/io-ico.c 2002-09-27 17:19:15.000000000 -0500
  3. +++ gdk-pixbuf-0.22.0-patched/gdk-pixbuf/io-ico.c 2005-10-27 11:28:23.000000000 -0500
  4. @@ -330,6 +330,9 @@
  5. State->HeaderSize+=I;
  6. + if (State->HeaderSize < 0)
  7. + return FALSE;
  8. +
  9. if (State->HeaderSize>State->BytesInHeaderBuf) {
  10. guchar *tmp=realloc(State->HeaderBuf,State->HeaderSize);
  11. if (!tmp)
  12. diff -NurdB gdk-pixbuf-0.22.0/gdk-pixbuf/io-xpm.c gdk-pixbuf-0.22.0-patched/gdk-pixbuf/io-xpm.c
  13. --- gdk-pixbuf-0.22.0/gdk-pixbuf/io-xpm.c 2001-03-01 15:16:28.000000000 -0500
  14. +++ gdk-pixbuf-0.22.0-patched/gdk-pixbuf/io-xpm.c 2005-10-27 11:29:14.000000000 -0500
  15. @@ -243,8 +243,8 @@
  16. break;
  17. else {
  18. if (numnames > 0) {
  19. - space -= 1;
  20. - strcat (color, " ");
  21. + strncat (color, " ", space);
  22. + space -= MIN (space, 1);
  23. }
  24. strncat (color, temp, space);
  25. @@ -281,7 +281,8 @@
  26. /* Fall through to the xpm_read_string. */
  27. case op_body:
  28. - xpm_read_string (h->infile, &h->buffer, &h->buffer_size);
  29. + if(!xpm_read_string (h->infile, &h->buffer, &h->buffer_size))
  30. + return NULL;
  31. return h->buffer;
  32. default:
  33. @@ -317,13 +318,6 @@
  34. return NULL;
  35. }
  36. -/* Destroy notification function for the pixbuf */
  37. -static void
  38. -free_buffer (guchar *pixels, gpointer data)
  39. -{
  40. - free (pixels);
  41. -}
  42. -
  43. static gboolean
  44. xpm_color_parse (const char *spec, XColor *color)
  45. {
  46. @@ -342,7 +336,8 @@
  47. gchar pixel_str[32];
  48. GHashTable *color_hash;
  49. _XPMColor *colors, *color, *fallbackcolor;
  50. - guchar *pixels, *pixtmp;
  51. + guchar *pixtmp;
  52. + GdkPixbuf* pixbuf;
  53. fallbackcolor = NULL;
  54. @@ -352,16 +347,33 @@
  55. return NULL;
  56. }
  57. sscanf (buffer, "%d %d %d %d", &w, &h, &n_col, &cpp);
  58. - if (cpp >= 32) {
  59. - g_warning ("XPM has more than 31 chars per pixel.");
  60. + if (cpp <= 0 || cpp >= 32) {
  61. + g_warning ("XPM has invalid number of chars per pixel.");
  62. return NULL;
  63. }
  64. + if (n_col <= 0 ||
  65. + n_col >= G_MAXINT / (cpp + 1) ||
  66. + n_col >= G_MAXINT / sizeof (_XPMColor)) {
  67. + g_warning ("XPM file has invalid number of colors");
  68. + return NULL;
  69. + }
  70. /* The hash is used for fast lookups of color from chars */
  71. color_hash = g_hash_table_new (g_str_hash, g_str_equal);
  72. - name_buf = g_new (gchar, n_col * (cpp + 1));
  73. - colors = g_new (_XPMColor, n_col);
  74. + name_buf = g_new (gchar, n_col * (cpp + 1));
  75. + if (!name_buf) {
  76. + g_warning ("Cannot allocate memory for loading XPM image");
  77. + g_hash_table_destroy (color_hash);
  78. + return NULL;
  79. + }
  80. + colors = g_new (_XPMColor, n_col);
  81. + if (!colors) {
  82. + g_warning ("Cannot allocate memory for loading XPM image");
  83. + g_hash_table_destroy (color_hash);
  84. + g_free (name_buf);
  85. + return NULL;
  86. + }
  87. for (cnt = 0; cnt < n_col; cnt++) {
  88. gchar *color_name;
  89. @@ -397,12 +409,8 @@
  90. fallbackcolor = color;
  91. }
  92. - if (is_trans)
  93. - pixels = malloc (w * h * 4);
  94. - else
  95. - pixels = malloc (w * h * 3);
  96. -
  97. - if (!pixels) {
  98. + pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, is_trans, 8, w, h);
  99. + if (!pixbuf) {
  100. g_hash_table_destroy (color_hash);
  101. g_free (colors);
  102. g_free (name_buf);
  103. @@ -410,7 +418,7 @@
  104. }
  105. wbytes = w * cpp;
  106. - pixtmp = pixels;
  107. + pixtmp = pixbuf->pixels;
  108. for (ycnt = 0; ycnt < h; ycnt++) {
  109. buffer = (*get_buf) (op_body, handle);
  110. @@ -443,9 +451,7 @@
  111. g_free (colors);
  112. g_free (name_buf);
  113. - return gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, is_trans, 8,
  114. - w, h, is_trans ? (w * 4) : (w * 3),
  115. - free_buffer, NULL);
  116. + return pixbuf;
  117. }
  118. /* Shared library entry point for file loading */