head 1.4; access; symbols pkgsrc-2013Q2:1.4.0.8 pkgsrc-2013Q2-base:1.4 pkgsrc-2012Q4:1.4.0.6 pkgsrc-2012Q4-base:1.4 pkgsrc-2011Q4:1.4.0.4 pkgsrc-2011Q4-base:1.4 pkgsrc-2011Q2:1.4.0.2 pkgsrc-2011Q2-base:1.4 pkgsrc-2011Q1:1.3.0.2 pkgsrc-2011Q1-base:1.3 pkgsrc-2010Q4:1.1.0.2 pkgsrc-2010Q4-base:1.1; locks; strict; comment @# @; 1.4 date 2011.05.02.11.15.42; author adam; state dead; branches; next 1.3; 1.3 date 2011.01.24.12.08.26; author wiz; state Exp; branches; next 1.2; 1.2 date 2011.01.13.13.52.52; author wiz; state Exp; branches; next 1.1; 1.1 date 2010.12.07.16.58.12; author drochner; state Exp; branches; next ; desc @@ 1.4 log @Changes 20110222: * Did a lot of work to improve the accuracy in remove overlap. Improved accuracy means that it is less likely to do the wrong thing. Problems happen when there are points or intersections very close to each other. (So quadratic glyphs are more likely to have problems than cubics simply because they have more points, on average). * Fix various error messages. * Remove some obsolete documentation. * Technical fixes to stroking code. * Add a miterlimit to stroking code. * FontForge was using the wrong MIME type for svg files. W3C has changed it and it's now "image/svg+xml" not "image/svg-xml" or "image/svg". * Since Inkscape images tend to be at unexpected y positions, force the view to rescale/recenter itself if the result after a paste/import is outside the current window. (Inkscape tends to put things at the top of a page, but the origin is at the bottom, and FF looks at the origin. * A line joint of 180 degrees (which shouldn't have happened in stroking, but did) caused an infinite loop. * Typo in add extrema code (again). * More... @ text @$NetBSD: patch-ak,v 1.3 2011/01/24 12:08:26 wiz Exp $ Fix build with png-1.5. --- gutils/gimagewritepng.c.orig 2010-04-29 17:52:54.000000000 +0000 +++ gutils/gimagewritepng.c @@@@ -53,6 +53,11 @@@@ static void (*_png_set_packing)(png_stru static void (*_png_set_filler)(png_structp,png_uint_32,int); static void (*_png_write_image)(png_structp,png_bytep*); static void (*_png_write_end)(png_structp,png_infop); +static void (*_png_longjmp)(png_structp, int); +static jmp_buf* (*_png_set_longjmp_fn)(png_structp,png_longjmp_ptr, size_t); +static void (*_png_set_IHDR)(png_structp,png_infop,png_uint_32,png_uint_32,int,int,int,int,int); +static void (*_png_set_PLTE)(png_structp,png_infop,png_colorp,int); +static void (*_png_set_tRNS)(png_structp,png_infop,png_bytep,int,png_color_16p); static int loadpng() { /* Oops someone might have libpng without libz. If we try to load libpng */ @@@@ -66,7 +71,7 @@@@ static int loadpng() { return( 0 ); } # if !defined(_LIBPNG12) - libpng = dlopen("libpng" SO_EXT,RTLD_LAZY); + libpng = dlopen("libpng15" SO_EXT,RTLD_LAZY); # ifdef SO_2_EXT if ( libpng==NULL ) libpng = dlopen("libpng" SO_2_EXT,RTLD_LAZY); @@@@ -100,6 +105,16 @@@@ return( 0 ); dlsym(libpng,"png_write_image"); _png_write_end = (void (*)(png_structp,png_infop)) dlsym(libpng,"png_write_end"); + _png_longjmp = (void (*)(png_structp, int)) + dlsym(libpng,"png_longjmp"); + _png_set_longjmp_fn = (jmp_buf* (*)(png_structp,png_longjmp_ptr,size_t)) + dlsym(libpng,"png_set_longjmp_fn"); + _png_set_IHDR = (void (*)(png_structp,png_infop,png_uint_32,png_uint_32,int,int,int,int,int)) + dlsym(libpng,"png_set_IHDR"); + _png_set_PLTE = (void (*)(png_structp,png_infop,png_colorp,int)) + dlsym(libpng,"png_set_PLTE"); + _png_set_tRNS = (void (*)(png_structp,png_infop,png_bytep,int,png_color_16p)) + dlsym(libpng,"png_set_tRNS"); if ( _png_create_write_struct && _png_create_info_struct && _png_destroy_write_struct && _png_init_io && _png_set_filler && _png_write_info && _png_set_packing && _png_write_image && _png_write_end) @@@@ -111,7 +126,11 @@@@ return( 0 ); static void user_error_fn(png_structp png_ptr, png_const_charp error_msg) { fprintf(stderr,"%s", error_msg ); +#if (PNG_LIBPNG_VER < 10500) longjmp(png_ptr->jmpbuf,1); +#else + _png_longjmp (png_ptr, 1); +#endif } static void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg) { @@@@ -124,6 +143,12 @@@@ int GImageWrite_Png(GImage *gi, FILE *fp png_infop info_ptr; png_byte **rows; int i; + int bit_depth; + int color_type; + int num_palette; + png_bytep trans_alpha = NULL; + png_color_16p trans_color = NULL; + png_colorp palette = NULL; if ( libpng==NULL ) if ( !loadpng()) @@@@ -142,75 +167,66 @@@@ return(false); return(false); } - if (setjmp(png_ptr->jmpbuf)) { + if (setjmp(*_png_set_longjmp_fn(png_ptr, longjmp, sizeof (jmp_buf)))) { _png_destroy_write_struct(&png_ptr, (png_infopp)NULL); return(false); } _png_init_io(png_ptr, fp); - info_ptr->width = base->width; - info_ptr->height = base->height; - info_ptr->bit_depth = 8; - info_ptr->valid = 0; - info_ptr->interlace_type = progressive; - if ( base->trans!=-1 ) { - info_ptr->num_trans = 1; - info_ptr->valid |= PNG_INFO_tRNS; + bit_depth = 8; + num_palette = base->clut==NULL?2:base->clut->clut_len; + if ( base->image_type==it_index || base->image_type==it_bitmap ) { + color_type = PNG_COLOR_TYPE_PALETTE; + if ( num_palette<=2 ) + bit_depth=1; + else if ( num_palette<=4 ) + bit_depth=2; + else if ( num_palette<=16 ) + bit_depth=4; + } else { + color_type = PNG_COLOR_TYPE_RGB; + if ( base->image_type == it_rgba ) + color_type = PNG_COLOR_TYPE_RGB_ALPHA; } + + _png_set_IHDR(png_ptr, info_ptr, base->width, base->height, + bit_depth, color_type, progressive, + PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); if ( base->image_type==it_index || base->image_type==it_bitmap ) { - info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; - info_ptr->valid |= PNG_INFO_PLTE; - info_ptr->num_palette = base->clut==NULL?2:base->clut->clut_len; - info_ptr->palette = (png_color *) galloc(info_ptr->num_palette*sizeof(png_color)); + palette = (png_color *) galloc(num_palette*sizeof(png_color)); if ( base->clut==NULL ) { - info_ptr->palette[0].red = info_ptr->palette[0].green = info_ptr->palette[0].blue = 0; - info_ptr->palette[1].red = info_ptr->palette[1].green = info_ptr->palette[1].blue = 0xff; + palette[0].red = palette[0].green = palette[0].blue = 0; + palette[1].red = palette[1].green = palette[1].blue = 0xff; } else { - for ( i=0; inum_palette; ++i ) { + for ( i=0; iclut->clut[i]; - info_ptr->palette[i].red = COLOR_RED(col); - info_ptr->palette[i].green = COLOR_GREEN(col); - info_ptr->palette[i].blue = COLOR_BLUE(col); + palette[i].red = COLOR_RED(col); + palette[i].green = COLOR_GREEN(col); + palette[i].blue = COLOR_BLUE(col); } } - if ( info_ptr->num_palette<=2 ) - info_ptr->bit_depth=1; - else if ( info_ptr->num_palette<=4 ) - info_ptr->bit_depth=2; - else if ( info_ptr->num_palette<=16 ) - info_ptr->bit_depth=4; - if ( info_ptr->num_palette<=16 ) + _png_set_PLTE(png_ptr, info_ptr, palette, num_palette); + if ( num_palette<=16 ) _png_set_packing(png_ptr); + if ( base->trans!=-1 ) { -#if ( PNG_LIBPNG_VER_MAJOR > 1 || PNG_LIBPNG_VER_MINOR > 2 ) - info_ptr->trans_alpha = galloc(1); - info_ptr->trans_alpha[0] = base->trans; -#else - info_ptr->trans = galloc(1); - info_ptr->trans[0] = base->trans; -#endif + trans_alpha = galloc(1); + trans_alpha[0] = base->trans; } } else { - info_ptr->color_type = PNG_COLOR_TYPE_RGB; - if ( base->image_type == it_rgba ) - info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA; - if ( base->trans!=-1 ) { -#if ( PNG_LIBPNG_VER_MAJOR > 1 || PNG_LIBPNG_VER_MINOR > 2 ) - info_ptr->trans_color.red = COLOR_RED(base->trans); - info_ptr->trans_color.green = COLOR_GREEN(base->trans); - info_ptr->trans_color.blue = COLOR_BLUE(base->trans); -#else - info_ptr->trans_values.red = COLOR_RED(base->trans); - info_ptr->trans_values.green = COLOR_GREEN(base->trans); - info_ptr->trans_values.blue = COLOR_BLUE(base->trans); -#endif + trans_color->red = COLOR_RED(base->trans); + trans_color->green = COLOR_GREEN(base->trans); + trans_color->blue = COLOR_BLUE(base->trans); } } + if ( base->trans!=-1 ) { + _png_set_tRNS(png_ptr, info_ptr, trans_alpha, 1, trans_color); + } _png_write_info(png_ptr, info_ptr); - if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) + if (color_type == PNG_COLOR_TYPE_RGB) _png_set_filler(png_ptr, '\0', PNG_FILLER_BEFORE); rows = galloc(base->height*sizeof(png_byte *)); @@@@ -221,12 +237,8 @@@@ return(false); _png_write_end(png_ptr, info_ptr); -#if ( PNG_LIBPNG_VER_MAJOR > 1 || PNG_LIBPNG_VER_MINOR > 2 ) - if ( info_ptr->trans_alpha!=NULL ) gfree(info_ptr->trans_alpha); -#else - if ( info_ptr->trans!=NULL ) gfree(info_ptr->trans); -#endif - if ( info_ptr->palette!=NULL ) gfree(info_ptr->palette); + if ( trans_alpha!=NULL ) gfree(trans_alpha); + if ( palette!=NULL ) gfree(palette); _png_destroy_write_struct(&png_ptr, &info_ptr); gfree(rows); return( 1 ); @@@@ -261,7 +273,11 @@@@ return( ret ); static void user_error_fn(png_structp png_ptr, png_const_charp error_msg) { fprintf(stderr, "%s\n", error_msg ); +#if (PNG_LIBPNG_VER < 10500) longjmp(png_ptr->jmpbuf,1); +#else + _png_longjmp (png_ptr, 1); +#endif } static void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg) { @@@@ -288,7 +304,7 @@@@ return(false); return(false); } - if (setjmp(png_ptr->jmpbuf)) { + if (setjmp(*_png_set_longjmp_fn(png_ptr, longjmp, sizeof (jmp_buf)))) { png_destroy_write_struct(&png_ptr, (png_infopp)NULL); return(false); } @ 1.3 log @Complete fix for png-1.5. @ text @d1 1 a1 1 $NetBSD: patch-ak,v 1.2 2011/01/13 13:52:52 wiz Exp $ @ 1.2 log @Update patches for png-1.5. @ text @d1 3 a3 1 $NetBSD: patch-ak,v 1.1 2010/12/07 16:58:12 drochner Exp $ d7 13 a19 1 @@@@ -66,7 +66,7 @@@@ static int loadpng() { d28 192 @ 1.1 log @-make this pkg work with pkg-1.4.x The fix is a hack. There is code to deal with png versions, but it is not complete for 1.4.x, and fooled by bl3 wrappers renaming the library behind the pkg's back. -patch format string problems leading to possible buffer overflow (CVE-2010-4259), from Redhat bug#659359 bump PKGREV @ text @d1 1 a1 1 $NetBSD$ d10 1 a10 1 + libpng = dlopen("libpng14" SO_EXT,RTLD_LAZY); @