[cinepaint] - Replacing the png patch with the upstream one (thx to Nick Black)
Jaromír Cápík
jcapik at fedoraproject.org
Mon Feb 24 14:18:04 UTC 2014
commit 8690e592836a012165d4a6ca2887c77155229494
Author: Jaromir Capik <jcapik at redhat.com>
Date: Mon Feb 24 15:18:46 2014 +0100
- Replacing the png patch with the upstream one (thx to Nick Black)
cinepaint-1.4-png.patch | 259 ++++++++++++++++++++---------------------------
cinepaint.spec | 5 +-
2 files changed, 116 insertions(+), 148 deletions(-)
---
diff --git a/cinepaint-1.4-png.patch b/cinepaint-1.4-png.patch
index 4e4e3fb..7aec6f2 100644
--- a/cinepaint-1.4-png.patch
+++ b/cinepaint-1.4-png.patch
@@ -1,22 +1,7 @@
-diff -Naur cinepaint-1.0-4.orig/plug-ins/png/png.c cinepaint-1.0-4/plug-ins/png/png.c
---- cinepaint-1.0-4.orig/plug-ins/png/png.c 2006-11-24 21:52:55.000000000 +0100
-+++ cinepaint-1.0-4/plug-ins/png/png.c 2013-10-30 19:01:01.298617565 +0100
-@@ -391,6 +391,14 @@
- guchar alpha[256], /* Index -> Alpha */
- *alpha_ptr; /* Temporary pointer */
-
-+ int width, height, bit_depth, color_type, nBands, num_palette, channels;
-+ png_colorp palette;
-+ png_charpp iccp_name;
-+ int iccp_compression_type;
-+ png_bytep iccp_profile;
-+ png_uint_32 iccp_proflen;
-+
-+
- /*
- * PNG 0.89 and newer have a sane, forwards compatible constructor.
- * Some SGI IRIX users will not have a new enough version though
-@@ -405,7 +413,7 @@
+diff -ur cinepaint/plug-ins/png/png.c cinepaint-png15/plug-ins/png/png.c
+--- cinepaint/plug-ins/png/png.c 2006-11-24 15:52:55.000000000 -0500
++++ cinepaint-png15/plug-ins/png/png.c 2013-03-02 03:37:33.304142225 -0500
+@@ -405,7 +405,7 @@
info = (png_infop)calloc(sizeof(png_info), 1);
#endif /* PNG_LIBPNG_VER > 88 */
@@ -25,103 +10,94 @@ diff -Naur cinepaint-1.0-4.orig/plug-ins/png/png.c cinepaint-1.0-4/plug-ins/png/
{
g_message ("%s\nPNG error. File corrupted?", filename);
return image;
-@@ -442,21 +450,23 @@
- */
-
- png_read_info(pp, info);
-+ png_get_IHDR(pp, info, (png_uint_32 *)&width, (png_uint_32 *)&height, &bit_depth, &color_type, NULL, NULL, NULL);
-+
-
- /*
- * Latest attempt, this should be my best yet :)
+@@ -448,15 +448,15 @@
*/
#ifndef WORDS_BIGENDIAN
- if(info->bit_depth == 16)
-+ if(bit_depth == 16)
++ if(png_get_bit_depth(pp,info) == 16)
png_set_swap(pp);
#endif
- if (info->color_type == PNG_COLOR_TYPE_GRAY && info->bit_depth < 8) {
-+ if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
++ if (png_get_color_type(pp,info) == PNG_COLOR_TYPE_GRAY && png_get_bit_depth(pp,info) < 8) {
png_set_expand(pp);
}
- if (info->color_type == PNG_COLOR_TYPE_PALETTE && info->bit_depth < 8) {
-+ if (color_type == PNG_COLOR_TYPE_PALETTE && bit_depth < 8) {
++ if (png_get_color_type(pp,info) == PNG_COLOR_TYPE_PALETTE && png_get_bit_depth(pp,info) < 8) {
png_set_packing(pp);
}
-@@ -464,8 +474,8 @@
+@@ -464,8 +464,8 @@
* Expand G+tRNS to GA, RGB+tRNS to RGBA
*/
- if (info->color_type != PNG_COLOR_TYPE_PALETTE &&
- (info->valid & PNG_INFO_tRNS)) {
-+ if (color_type != PNG_COLOR_TYPE_PALETTE &&
-+ png_get_valid(pp, info, PNG_INFO_tRNS)) {
++ if (png_get_color_type(pp,info) != PNG_COLOR_TYPE_PALETTE &&
++ (png_get_valid(pp,info,PNG_INFO_tRNS) & PNG_INFO_tRNS)) {
png_set_expand(pp);
}
-@@ -482,7 +492,7 @@
+@@ -482,7 +482,7 @@
#if PNG_LIBPNG_VER > 99
if (png_get_valid(pp, info, PNG_INFO_tRNS) &&
- info->color_type == PNG_COLOR_TYPE_PALETTE)
-+ color_type == PNG_COLOR_TYPE_PALETTE)
++ png_get_color_type(pp, info) == PNG_COLOR_TYPE_PALETTE)
{
png_get_tRNS(pp, info, &alpha_ptr, &num, NULL);
/* Copy the existing alpha values from the tRNS chunk */
-@@ -504,10 +514,11 @@
- */
+@@ -505,9 +505,9 @@
png_read_update_info(pp, info);
--
+
- if(info->bit_depth==16)
-+ png_get_IHDR(pp, info, (png_uint_32 *)&width, (png_uint_32 *)&height, &bit_depth, &color_type, NULL, NULL, NULL);
-+
-+ if(bit_depth==16)
++ if(png_get_bit_depth(pp,info)==16)
{
- switch (info->color_type)
-+ switch (color_type)
++ switch (png_get_color_type(pp, info))
{
case PNG_COLOR_TYPE_RGB : /* RGB */
bpp = 6;
-@@ -545,7 +556,7 @@
+@@ -545,7 +545,7 @@
}
else
{
- switch (info->color_type)
-+ switch (color_type)
++ switch (png_get_color_type(pp, info))
{
case PNG_COLOR_TYPE_RGB : /* RGB */
bpp = 3;
-@@ -582,7 +593,7 @@
+@@ -582,7 +582,7 @@
};
}
- image = gimp_image_new(info->width, info->height, image_type);
-+ image = gimp_image_new(width, height, image_type);
++ image = gimp_image_new(png_get_image_width(pp,info), png_get_image_height(pp,info), image_type);
if (image == -1)
{
g_message("Can't allocate new image\n%s", filename);
-@@ -595,7 +606,7 @@
+@@ -595,7 +595,7 @@
* Create the "background" layer to hold the image...
*/
- layer = gimp_layer_new(image, _("Background"), info->width, info->height,
-+ layer = gimp_layer_new(image, _("Background"), width, height,
++ layer = gimp_layer_new(image, _("Background"), png_get_image_width(pp,info), png_get_image_height(pp,info),
layer_type, 100, NORMAL_MODE);
gimp_image_add_layer(image, layer, 0);
-@@ -627,20 +638,22 @@
+@@ -627,20 +627,23 @@
empty= 0; /* by default assume no full transparent palette entries */
- if (info->color_type & PNG_COLOR_MASK_PALETTE) {
-+ if (color_type & PNG_COLOR_MASK_PALETTE) {
++ if (png_get_color_type(pp, info) & PNG_COLOR_MASK_PALETTE) {
++ png_colorp palette;
++ int num_palette;
++ png_get_PLTE(pp, info, &palette, &num_palette);
+
-+ png_get_PLTE(pp, info, &palette, &num_palette);
#if PNG_LIBPNG_VER > 99
if (png_get_valid(pp, info, PNG_INFO_tRNS)) {
@@ -130,104 +106,114 @@ diff -Naur cinepaint-1.0-4.orig/plug-ins/png/png.c cinepaint-1.0-4/plug-ins/png/
- gimp_image_set_cmap(image, (guchar *) (info->palette + empty),
- info->num_palette - empty);
-+ gimp_image_set_cmap(image, (guchar *) (palette + empty),
-+ num_palette - empty);
++ gimp_image_set_cmap(image, (guchar *) &palette + empty,num_palette - empty);
} else {
- gimp_image_set_cmap(image, (guchar *)info->palette, info->num_palette);
-+ gimp_image_set_cmap(image, (guchar *)palette, num_palette);
++ gimp_image_set_cmap(image, (guchar *)&palette, num_palette);
}
#else
- gimp_image_set_cmap(image, (guchar *)info->palette, info->num_palette);
-+ gimp_image_set_cmap(image, (guchar *)palette, num_palette);
++ gimp_image_set_cmap(image, (guchar *)&palette, num_palette);
#endif /* PNG_LIBPNG_VER > 99 */
}
-@@ -659,18 +672,20 @@
+@@ -659,18 +662,18 @@
*/
tile_height = gimp_tile_height ();
- pixel = g_new(guchar, tile_height * info->width * bpp);
-+ pixel = g_new(guchar, tile_height * width * bpp);
++ pixel = g_new(guchar, tile_height * png_get_image_width(pp,info) * bpp);
pixels = g_new(guchar *, tile_height);
- if(info->bit_depth==16)
-+ channels = png_get_channels(pp, info);
-+
-+ if(bit_depth==16)
++ if(png_get_bit_depth(pp,info)==16)
{
for (i = 0; i < tile_height; i ++)
- pixels[i] = pixel + info->width * info->channels * i * 2;
-+ pixels[i] = pixel + width * channels * i * 2;
++ pixels[i] = pixel + png_get_image_width(pp,info) * png_get_channels(pp,info) * i * 2;
}
else
{
for (i = 0; i < tile_height; i ++)
- pixels[i] = pixel + info->width * info->channels * i;
-+ pixels[i] = pixel + width * channels * i;
++ pixels[i] = pixel + png_get_image_width(pp,info) * png_get_channels(pp,info) * i;
}
for (pass = 0; pass < num_passes; pass ++)
-@@ -680,11 +695,11 @@
+@@ -680,11 +683,11 @@
*/
for (begin = 0, end = tile_height;
- begin < info->height;
-+ begin < height;
++ begin < png_get_image_height(pp,info);
begin += tile_height, end += tile_height)
{
- if (end > info->height)
- end = info->height;
-+ if (end > height)
-+ end = height;
++ if (end > png_get_image_height(pp,info))
++ end = png_get_image_height(pp,info);
num = end - begin;
-@@ -697,20 +712,23 @@
+@@ -697,21 +700,24 @@
gimp_pixel_rgn_set_rect(&pixel_rgn, pixel, 0, begin,
drawable->width, num);
- gimp_progress_update(((double)pass + (double)end / (double)info->height) /
-+ gimp_progress_update(((double)pass + (double)end / (double)height) /
++ gimp_progress_update(((double)pass + (double)end / (double)png_get_image_height(pp,info)) /
(double)num_passes);
};
};
#if defined(PNG_iCCP_SUPPORTED)
++{
/* set icc profile */
- if (info->iccp_proflen > 0) {
- gimp_image_set_icc_profile_by_mem (image, info->iccp_proflen,
- info->iccp_profile,
-+ png_get_iCCP(pp, info, iccp_name, &iccp_compression_type, &iccp_profile, &iccp_proflen);
-+
-+
-+ if (iccp_proflen > 0) {
-+ gimp_image_set_icc_profile_by_mem (image, iccp_proflen,
-+ iccp_profile,
- ICC_IMAGE_PROFILE);
+- ICC_IMAGE_PROFILE);
++ png_charpp name;
++ int ctype = PNG_COMPRESSION_TYPE_BASE;
++ png_bytepp prof;
++ png_uint_32 proflen;
++ if (png_get_iCCP(pp,info,name,&ctype,prof,&proflen) > 0) {
++ gimp_image_set_icc_profile_by_mem (image, proflen, prof, ICC_IMAGE_PROFILE);
printf ("%s:%d %s() set embedded profile \"%s\"\n",
- __FILE__,__LINE__,__func__,
+- __FILE__,__LINE__,__func__,
- info->iccp_name);
-+ iccp_name);
++ __FILE__,__LINE__,__func__,(const char *)name);
}
++}
#endif
-@@ -809,6 +827,15 @@
+ /*
+@@ -774,6 +780,8 @@
+ * 'save_image ()' - Save the specified image to a PNG file.
+ */
+
++typedef png_info *png_infop;
++
+ static gint
+ save_image (gchar *filename, /* I - File to save to */
+ gint32 image_ID, /* I - Image to save */
+@@ -794,7 +802,7 @@
+ GPixelRgn pixel_rgn; /* Pixel region for layer */
+ png_structp pp; /* PNG read pointer */
+ png_infop info; /* PNG info pointer */
+- gint num_colors; /* Number of colors in colormap */
++ gint num_colors = 0; /* Number of colors in colormap */
+ gint offx, offy; /* Drawable offsets from origin */
+ guchar **pixels, /* Pixel rows */
+ *fixed, /* Fixed-up pixel data */
+@@ -808,6 +816,7 @@
+ blue; /* Used for palette background */
time_t cutime; /* Time since epoch */
struct tm *gmt; /* GMT broken down */
++ int bit_depth,color_type;
-+ // get width, height, bit-depth and color-type
-+ int width, height, bit_depth, color_type, nBands, interlaced_type;
-+ int valid, palette, num_palette;
-+
-+ png_charpp iccp_name;
-+ int iccp_compression_type;
-+ png_bytep iccp_profile;
-+ png_uint_32 iccp_proflen;
-+
/*
* PNG 0.89 and newer have a sane, forwards compatible constructor.
- * Some SGI IRIX users will not have a new enough version though
-@@ -824,7 +851,7 @@
+@@ -824,7 +833,7 @@
info = (png_infop)calloc(sizeof(png_info), 1);
#endif /* PNG_LIBPNG_VER > 88 */
@@ -236,20 +222,18 @@ diff -Naur cinepaint-1.0-4.orig/plug-ins/png/png.c cinepaint-1.0-4/plug-ins/png/
{
g_message ("%s\nPNG error. Couldn't save image", filename);
return 0;
-@@ -863,9 +890,9 @@
+@@ -863,10 +872,6 @@
png_set_compression_level (pp, pngvals.compression_level);
- info->width = drawable->width;
- info->height = drawable->height;
- info->interlace_type = pngvals.interlaced;
-+ width = drawable->width;
-+ height = drawable->height;
-+ interlaced_type = pngvals.interlaced;
-
+-
/*
* Set color type and remember bytes per pixel count
-@@ -874,71 +901,71 @@
+ */
+@@ -874,71 +879,69 @@
switch (type)
{
case RGB_IMAGE :
@@ -289,9 +273,8 @@ diff -Naur cinepaint-1.0-4.orig/plug-ins/png/png.c cinepaint-1.0-4/plug-ins/png/
- info->num_palette= num_colors;
+ bit_depth = 8;
+ color_type = PNG_COLOR_TYPE_PALETTE;
-+ valid |= PNG_INFO_PLTE;
-+ palette= (png_colorp) gimp_image_get_cmap(image_ID, &num_colors);
-+ num_palette= num_colors;
++ void *plte = gimp_image_get_cmap(image_ID, &num_colors);
++ png_set_PLTE(pp,info,plte,num_colors);
break;
case INDEXEDA_IMAGE :
bpp = 2;
@@ -329,7 +312,8 @@ diff -Naur cinepaint-1.0-4.orig/plug-ins/png/png.c cinepaint-1.0-4/plug-ins/png/
+ bit_depth = 16;
bpp = 4;
break;
- case U16_INDEXED_IMAGE :
+- case U16_INDEXED_IMAGE :
++ case U16_INDEXED_IMAGE :{
bpp = 2;
- info->bit_depth = 16;
- info->color_type = PNG_COLOR_TYPE_PALETTE;
@@ -338,11 +322,11 @@ diff -Naur cinepaint-1.0-4.orig/plug-ins/png/png.c cinepaint-1.0-4/plug-ins/png/
- info->num_palette= num_colors;
+ bit_depth = 16;
+ color_type = PNG_COLOR_TYPE_PALETTE;
-+ valid |= PNG_INFO_PLTE;
-+ palette= (png_colorp) gimp_image_get_cmap(image_ID, &num_colors);
-+ num_palette= num_colors;
++ void *plte = gimp_image_get_cmap(image_ID, &num_colors);
++ png_set_PLTE(pp,info,plte,num_colors);
break;
- case U16_INDEXEDA_IMAGE :
+- case U16_INDEXEDA_IMAGE :
++ }case U16_INDEXEDA_IMAGE :
bpp = 4;
- info->bit_depth = 16;
- info->color_type = PNG_COLOR_TYPE_PALETTE;
@@ -351,7 +335,7 @@ diff -Naur cinepaint-1.0-4.orig/plug-ins/png/png.c cinepaint-1.0-4/plug-ins/png/
respin_cmap (pp, info, image_ID); /* fix up transparency */
break;
default:
-@@ -950,13 +977,13 @@
+@@ -950,16 +953,21 @@
* Fix bit depths for (possibly) smaller colormap images
*/
@@ -362,92 +346,73 @@ diff -Naur cinepaint-1.0-4.orig/plug-ins/png/png.c cinepaint-1.0-4/plug-ins/png/
- info->bit_depth= 2;
- else if (info->num_palette <= 16)
- info->bit_depth= 4;
-+ if (valid & PNG_INFO_PLTE) {
-+ if (num_palette <= 2)
++ if (png_get_valid(pp,info,PNG_INFO_PLTE) & PNG_INFO_PLTE) {
++ if (num_colors <= 2)
+ bit_depth= 1;
-+ else if (num_palette <= 4)
++ else if (num_colors <= 4)
+ bit_depth= 2;
-+ else if (num_palette <= 16)
++ else if (num_colors <= 16)
+ bit_depth= 4;
/* otherwise the default is fine */
}
-@@ -971,9 +998,13 @@
- png_set_iCCP (pp, info,
- gimp_image_get_icc_profile_description (image_ID, ICC_IMAGE_PROFILE),
- 0, buffer, size);
-+
-+ png_get_iCCP(pp, info, iccp_name, &iccp_compression_type, &iccp_profile, &iccp_proflen);
-+
++ png_set_IHDR(pp,info,drawable->width,drawable->height,
++ bit_depth,color_type,pngvals.interlaced,
++ PNG_COMPRESSION_TYPE_DEFAULT,
++ PNG_FILTER_TYPE_DEFAULT);
+
+ // write icc profile
+ #if defined(PNG_iCCP_SUPPORTED)
+ if (gimp_image_has_icc_profile (image_ID, ICC_IMAGE_PROFILE)) {
+@@ -973,7 +981,7 @@
+ 0, buffer, size);
printf ("%s:%d %s() embedd icc profile \"%s\"\n",
__FILE__,__LINE__,__func__,
- info->iccp_name);
-+ *iccp_name);
++ gimp_image_get_icc_profile_description (image_ID, ICC_IMAGE_PROFILE));
}
#endif
-@@ -1024,6 +1055,7 @@
-
- #endif /* PNG_LIBPNG_VER > 99 */
-
-+ png_set_IHDR(pp, info, width, height, bit_depth, color_type, interlaced_type, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
- png_write_info (pp, info);
-
- /*
-@@ -1039,13 +1071,13 @@
+@@ -1039,13 +1047,13 @@
* Convert unpacked pixels to packed if necessary
*/
- if (info->color_type == PNG_COLOR_TYPE_PALETTE && info->bit_depth < 8)
-+ if (color_type == PNG_COLOR_TYPE_PALETTE && bit_depth < 8)
++ if (png_get_color_type(pp, info) == PNG_COLOR_TYPE_PALETTE && png_get_bit_depth(pp,info) < 8)
png_set_packing(pp);
/* Set swapping for 16 bit per sample images */
#ifndef WORDS_BIGENDIAN
- if (info->bit_depth == 16)
-+ if (bit_depth == 16)
++ if (png_get_bit_depth(pp,info) == 16)
png_set_swap(pp);
#endif
-@@ -1077,7 +1109,7 @@
+@@ -1077,7 +1085,7 @@
num = end - begin;
gimp_pixel_rgn_get_rect (&pixel_rgn, pixel, 0, begin, drawable->width, num);
- if (info->valid & PNG_INFO_tRNS) {
-+ if (valid & PNG_INFO_tRNS) {
++ if (png_get_valid(pp,info,PNG_INFO_tRNS) & PNG_INFO_tRNS) {
for (i = 0; i < num; ++i) {
fixed= pixels[i];
for (k = 0; k < drawable->width; ++k) {
-@@ -1085,7 +1117,7 @@
+@@ -1085,7 +1093,7 @@
}
}
/* Forgot this case before, what if there are too many colors? */
- } else if (info->valid & PNG_INFO_PLTE && bpp == 2) {
-+ } else if (valid & PNG_INFO_PLTE && bpp == 2) {
++ } else if (png_get_valid(pp,info,PNG_INFO_PLTE) & PNG_INFO_PLTE && bpp == 2) {
for (i = 0; i < num; ++i) {
fixed= pixels[i];
for (k = 0; k < drawable->width; ++k) {
-@@ -1097,7 +1129,7 @@
+@@ -1097,7 +1105,7 @@
png_write_rows (pp, pixels, num);
gimp_progress_update (((double)pass + (double)end /
- (double)info->height) / (double)num_passes);
-+ (double)height) / (double)num_passes);
++ (double)png_get_image_height(pp,info)) / (double)num_passes);
};
};
-@@ -1157,9 +1189,9 @@
- png_set_PLTE(pp, info, (png_colorp) before, colors);
- }
- #else
-- info->valid |= PNG_INFO_PLTE;
-- info->palette= (png_colorp) before;
-- info->num_palette= colors;
-+ valid |= PNG_INFO_PLTE;
-+ palette= (png_colorp) before;
-+ num_palette= colors;
- #endif /* PNG_LIBPNG_VER > 99 */
-
- }
diff --git a/cinepaint.spec b/cinepaint.spec
index 13928a9..e9002e2 100644
--- a/cinepaint.spec
+++ b/cinepaint.spec
@@ -4,7 +4,7 @@
Name: cinepaint
Version: 1.4
-Release: 4%{?dist}
+Release: 5%{?dist}
Summary: Painting and image retouching program
Group: Applications/Multimedia
@@ -237,6 +237,9 @@ update-desktop-database %{_datadir}/applications > /dev/null 2>&1 || :
%{_datadir}/aclocal/%{name}.m4
%changelog
+* Mon Feb 24 2014 Jaromir Capik <jcapik at redhat.com> - 1.4-5
+- Replacing the png patch with the upstream one (thx to Nick Black)
+
* Mon Feb 17 2014 Jaromir Capik <jcapik at redhat.com> - 1.4-4
- Fixing format-security flaws (#1037014)
More information about the scm-commits
mailing list