]> git.imager.perl.org - imager.git/commitdiff
PNG re-work: provide perl level access to the libpng version number
authorTony Cook <tony@develop-help.com>
Tue, 14 Jun 2011 13:34:11 +0000 (23:34 +1000)
committerTony Cook <tony@develop-help.com>
Sun, 29 Apr 2012 03:40:55 +0000 (13:40 +1000)
PNG/PNG.xs
PNG/impng.c
PNG/impng.h
PNG/t/10png.t

index af235869d1adfdaedeb1d2f8f4ccd110871ee2c2..cc90923abdcb5ed2c412627130a114db21b37b0b 100644 (file)
@@ -22,5 +22,8 @@ i_writepng_wiol(im, ig)
     Imager::ImgRaw     im
         Imager::IO     ig
 
+unsigned
+i_png_lib_version()
+
 BOOT:
        PERL_INITIALIZE_IMAGER_CALLBACKS;
index d831eb3a625c0a5ab072b0c41d7fcd0ae5597c14..a42c3d2538936def1c10c0593be9bd7037f811ce 100644 (file)
@@ -29,7 +29,10 @@ static int CC2C[PNG_COLOR_MASK_PALETTE|PNG_COLOR_MASK_COLOR|PNG_COLOR_MASK_ALPHA
 
 #define PNG_BYTES_TO_CHECK 4
  
-
+unsigned
+i_png_lib_version(void) {
+  return png_access_version_number();
+}
 
 static void
 wiol_read_data(png_structp png_ptr, png_bytep data, png_size_t length) {
@@ -115,6 +118,7 @@ i_writepng_wiol(i_img *im, io_glue *ig) {
    * implementation ever matches the documentation.
    *
    * https://sourceforge.net/tracker/?func=detail&atid=105624&aid=3314943&group_id=5624
+   * fixed in libpng 1.5.3
   */
   if (width > PNG_DIM_MAX || height > PNG_DIM_MAX) {
     i_push_error(0, "Image too large for PNG");
@@ -251,6 +255,8 @@ i_readpng_wiol(io_glue *ig) {
   int channels,pass;
   unsigned int sig_read;
   i_png_read_state rs;
+  i_img_dim wmax, hmax;
+  size_t bytes;
 
   rs.warnings = NULL;
   sig_read  = 0;
@@ -280,6 +286,9 @@ i_readpng_wiol(io_glue *ig) {
     cleanup_read_state(&rs);
     return NULL;
   }
+  
+  /* we do our own limit checks */
+  png_set_user_limits(png_ptr, PNG_DIM_MAX, PNG_DIM_MAX);
 
   png_set_sig_bytes(png_ptr, sig_read);
   png_read_info(png_ptr, info_ptr);
index afd5af1bbbe7c0bb9941cf7113f6e16cca627ec9..ed4f180df99250206f4d18731ed438f79409e7f4 100644 (file)
@@ -5,5 +5,6 @@
 
 i_img    *i_readpng_wiol(io_glue *ig);
 undef_int i_writepng_wiol(i_img *im, io_glue *ig);
+unsigned i_png_lib_version(void);
 
 #endif
index 759a266a3de543bf6adfd37b5fc3d07039d1df2e..1d3b3e49854f95f7527a632b80c65b86702a5922 100644 (file)
@@ -15,6 +15,8 @@ $Imager::formats{"png"}
 
 plan tests => 39;
 
+diag("Library version " . Imager::File::PNG::i_png_lib_version());
+
 my $green  = i_color_new(0,   255, 0,   255);
 my $blue   = i_color_new(0,   0,   255, 255);
 my $red    = i_color_new(255, 0,   0,   255);