summaryrefslogtreecommitdiffstats
path: root/libpng/pngget.c
diff options
context:
space:
mode:
authordimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2008-01-16 19:20:21 (GMT)
committerdimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2008-01-16 19:20:21 (GMT)
commit8dab665567c9dffaa3f5fea198fc2110d536594d (patch)
tree78bac4e928b25e139605aceefa82537f378d8af0 /libpng/pngget.c
parentd3461a1c31f008345d784dc3e819047bc5265c30 (diff)
downloadDoxygen-8dab665567c9dffaa3f5fea198fc2110d536594d.zip
Doxygen-8dab665567c9dffaa3f5fea198fc2110d536594d.tar.gz
Doxygen-8dab665567c9dffaa3f5fea198fc2110d536594d.tar.bz2
Release-1.5.4
Diffstat (limited to 'libpng/pngget.c')
-rw-r--r--libpng/pngget.c140
1 files changed, 62 insertions, 78 deletions
diff --git a/libpng/pngget.c b/libpng/pngget.c
index f180f3d..a0e90bb 100644
--- a/libpng/pngget.c
+++ b/libpng/pngget.c
@@ -1,9 +1,9 @@
/* pngget.c - retrieval of values from info struct
*
- * libpng 1.2.1 - December 12, 2001
+ * Last changed in libpng 1.2.15 January 5, 2007
* For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2001 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2007 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/
@@ -11,6 +11,8 @@
#define PNG_INTERNAL
#include "png.h"
+#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
+
png_uint_32 PNGAPI
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
{
@@ -510,8 +512,11 @@ png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
png_sPLT_tpp spalettes)
{
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
+ {
*spalettes = info_ptr->splt_palettes;
- return ((png_uint_32)info_ptr->splt_palettes_num);
+ return ((png_uint_32)info_ptr->splt_palettes_num);
+ }
+ return (0);
}
#endif
@@ -540,14 +545,15 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
bit_depth != NULL && color_type != NULL)
{
- int pixel_depth, channels;
- png_uint_32 rowbytes_per_pixel;
-
png_debug1(1, "in %s retrieval function\n", "IHDR");
*width = info_ptr->width;
*height = info_ptr->height;
*bit_depth = info_ptr->bit_depth;
+ if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
+ png_error(png_ptr, "Invalid bit depth");
*color_type = info_ptr->color_type;
+ if (info_ptr->color_type > 6)
+ png_error(png_ptr, "Invalid color type");
if (compression_type != NULL)
*compression_type = info_ptr->compression_type;
if (filter_type != NULL)
@@ -556,17 +562,16 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
*interlace_type = info_ptr->interlace_type;
/* check for potential overflow of rowbytes */
- if (*color_type == PNG_COLOR_TYPE_PALETTE)
- channels = 1;
- else if (*color_type & PNG_COLOR_MASK_COLOR)
- channels = 3;
- else
- channels = 1;
- if (*color_type & PNG_COLOR_MASK_ALPHA)
- channels++;
- pixel_depth = *bit_depth * channels;
- rowbytes_per_pixel = (pixel_depth + 7) >> 3;
- if ((*width > PNG_MAX_UINT/rowbytes_per_pixel))
+ if (*width == 0 || *width > PNG_UINT_31_MAX)
+ png_error(png_ptr, "Invalid image width");
+ if (*height == 0 || *height > PNG_UINT_31_MAX)
+ png_error(png_ptr, "Invalid image height");
+ if (info_ptr->width > (PNG_UINT_32_MAX
+ >> 3) /* 8-byte RGBA pixels */
+ - 64 /* bigrowbuf hack */
+ - 1 /* filter byte */
+ - 7*8 /* rounding of width to multiple of 8 pixels */
+ - 8) /* extra max_pixel_depth pad */
{
png_warning(png_ptr,
"Width too large for libpng to process image data.");
@@ -798,8 +803,11 @@ png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
png_unknown_chunkpp unknowns)
{
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
+ {
*unknowns = info_ptr->unknown_chunks;
- return ((png_uint_32)info_ptr->unknown_chunks_num);
+ return ((png_uint_32)info_ptr->unknown_chunks_num);
+ }
+ return (0);
}
#endif
@@ -819,99 +827,75 @@ png_get_user_chunk_ptr(png_structp png_ptr)
}
#endif
-
+#ifdef PNG_WRITE_SUPPORTED
png_uint_32 PNGAPI
png_get_compression_buffer_size(png_structp png_ptr)
{
return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
}
-
+#endif
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
-/* this function was added to libpng 1.2.0 and should exist by default*/
+#ifndef PNG_1_0_X
+/* this function was added to libpng 1.2.0 and should exist by default */
png_uint_32 PNGAPI
png_get_asm_flags (png_structp png_ptr)
{
- return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L);
+ /* obsolete, to be removed from libpng-1.4.0 */
+ return (png_ptr? 0L: 0L);
}
/* this function was added to libpng 1.2.0 and should exist by default */
png_uint_32 PNGAPI
png_get_asm_flagmask (int flag_select)
{
- png_uint_32 settable_asm_flags = 0;
-
- if (flag_select & PNG_SELECT_READ)
- settable_asm_flags |=
- PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
- PNG_ASM_FLAG_MMX_READ_INTERLACE |
- PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
- PNG_ASM_FLAG_MMX_READ_FILTER_UP |
- PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
- PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
- /* no non-MMX flags yet */
-
-#if 0
- /* GRR: no write-flags yet, either, but someday... */
- if (flag_select & PNG_SELECT_WRITE)
- settable_asm_flags |=
- PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
-#endif /* 0 */
-
- return settable_asm_flags; /* _theoretically_ settable capabilities only */
+ /* obsolete, to be removed from libpng-1.4.0 */
+ flag_select=flag_select;
+ return 0L;
}
-#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
-
-#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
/* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
/* this function was added to libpng 1.2.0 */
png_uint_32 PNGAPI
png_get_mmx_flagmask (int flag_select, int *compilerID)
{
- png_uint_32 settable_mmx_flags = 0;
-
- if (flag_select & PNG_SELECT_READ)
- settable_mmx_flags |=
- PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
- PNG_ASM_FLAG_MMX_READ_INTERLACE |
- PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
- PNG_ASM_FLAG_MMX_READ_FILTER_UP |
- PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
- PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
-#if 0
- /* GRR: no MMX write support yet, but someday... */
- if (flag_select & PNG_SELECT_WRITE)
- settable_mmx_flags |=
- PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
-#endif /* 0 */
-
- if (compilerID != NULL) {
-#ifdef PNG_USE_PNGVCRD
- *compilerID = 1; /* MSVC */
-#else
-#ifdef PNG_USE_PNGGCCRD
- *compilerID = 2; /* gcc/gas */
-#else
- *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
-#endif
-#endif
- }
-
- return settable_mmx_flags; /* _theoretically_ settable capabilities only */
+ /* obsolete, to be removed from libpng-1.4.0 */
+ flag_select=flag_select;
+ *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
+ return 0L;
}
/* this function was added to libpng 1.2.0 */
png_byte PNGAPI
png_get_mmx_bitdepth_threshold (png_structp png_ptr)
{
- return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0);
+ /* obsolete, to be removed from libpng-1.4.0 */
+ return (png_ptr? 0: 0);
}
/* this function was added to libpng 1.2.0 */
png_uint_32 PNGAPI
png_get_mmx_rowbytes_threshold (png_structp png_ptr)
{
- return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L);
+ /* obsolete, to be removed from libpng-1.4.0 */
+ return (png_ptr? 0L: 0L);
}
-#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
+#endif /* ?PNG_1_0_X */
+#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
+
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+/* these functions were added to libpng 1.2.6 */
+png_uint_32 PNGAPI
+png_get_user_width_max (png_structp png_ptr)
+{
+ return (png_ptr? png_ptr->user_width_max : 0);
+}
+png_uint_32 PNGAPI
+png_get_user_height_max (png_structp png_ptr)
+{
+ return (png_ptr? png_ptr->user_height_max : 0);
+}
+#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
+
+
+#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */