/* png.c - location for general purpose libpng functions
*
- * Last changed in libpng 1.5.6 [November 3, 2011]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
* Copyright (c) 1998-2011 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.)
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_5_6 Your_png_h_is_not_version_1_5_6;
+typedef png_libpng_version_1_5_7 Your_png_h_is_not_version_1_5_7;
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
if (png_ptr == NULL)
return (NULL);
+ if (ptime->year > 9999 /* RFC1123 limitation */ ||
+ ptime->month == 0 || ptime->month > 12 ||
+ ptime->day == 0 || ptime->day > 31 ||
+ ptime->hour > 23 || ptime->minute > 59 ||
+ ptime->second > 60)
+ {
+ png_warning(png_ptr, "Ignoring invalid time value");
+ return (NULL);
+ }
+
{
size_t pos = 0;
- char number_buf[5]; /* enough for a four digit year */
+ char number_buf[5]; /* enough for a four-digit year */
# define APPEND_STRING(string)\
pos = png_safecat(png_ptr->time_buffer, sizeof png_ptr->time_buffer,\
if (pos < (sizeof png_ptr->time_buffer)-1)\
png_ptr->time_buffer[pos++] = (ch)
- APPEND_NUMBER(PNG_NUMBER_FORMAT_u, (unsigned)ptime->day % 32);
+ APPEND_NUMBER(PNG_NUMBER_FORMAT_u, (unsigned)ptime->day);
APPEND(' ');
- APPEND_STRING(short_months[(ptime->month - 1) % 12]);
+ APPEND_STRING(short_months[(ptime->month - 1)]);
APPEND(' ');
APPEND_NUMBER(PNG_NUMBER_FORMAT_u, ptime->year);
APPEND(' ');
- APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->hour % 24);
+ APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->hour);
APPEND(':');
- APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->minute % 60);
+ APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->minute);
APPEND(':');
- APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->second % 61);
+ APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->second);
APPEND_STRING(" +0000"); /* This reliably terminates the buffer */
# undef APPEND
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
- "libpng version 1.5.6 - November 3, 2011" PNG_STRING_NEWLINE \
+ "libpng version 1.5.7 - December 15, 2011" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2011 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE;
# else
- return "libpng version 1.5.6 - November 3, 2011\
+ return "libpng version 1.5.7 - December 15, 2011\
Copyright (c) 1998-2011 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
static png_uint_32
png_8bit_l2[128] =
{
-# if PNG_DO_BC
+# ifdef PNG_DO_BC
for (i=128;i<256;++i) { .5 - l(i/255)/l(2)*65536*65536; }
-# endif
+# else
4270715492U, 4222494797U, 4174646467U, 4127164793U, 4080044201U, 4033279239U,
3986864580U, 3940795015U, 3895065449U, 3849670902U, 3804606499U, 3759867474U,
3715449162U, 3671346997U, 3627556511U, 3584073329U, 3540893168U, 3498011834U,
324227938U, 298676034U, 273229066U, 247886176U, 222646516U, 197509248U,
172473545U, 147538590U, 122703574U, 97967701U, 73330182U, 48790236U,
24347096U, 0U
+# endif
+
#if 0
/* The following are the values for 16-bit tables - these work fine for the
* 8-bit conversions but produce very slightly larger errors in the 16-bit
* integer bits (the top 4) simply determine a shift.
*
* The worst case is the 16-bit distinction between 65535 and 65534, this
- * requires perhaps spurious accuracty in the decoding of the logarithm to
+ * requires perhaps spurious accuracy in the decoding of the logarithm to
* distinguish log2(65535/65534.5) - 10^-5 or 17 bits. There is little chance
* of getting this accuracy in practice.
*
static png_uint_32
png_32bit_exp[16] =
{
-# if PNG_DO_BC
+# ifdef PNG_DO_BC
for (i=0;i<16;++i) { .5 + e(-i/16*l(2))*2^32; }
-# endif
+# else
/* NOTE: the first entry is deliberately set to the maximum 32-bit value. */
4294967295U, 4112874773U, 3938502376U, 3771522796U, 3611622603U, 3458501653U,
3311872529U, 3171459999U, 3037000500U, 2908241642U, 2784941738U, 2666869345U,
2553802834U, 2445529972U, 2341847524U, 2242560872U
+# endif
};
/* Adjustment table; provided to explain the numbers in the code below. */
-#if PNG_DO_BC
+#ifdef PNG_DO_BC
for (i=11;i>=0;--i){ print i, " ", (1 - e(-(2^i)/65536*l(2))) * 2^(32-i), "\n"}
11 44937.64284865548751208448
10 45180.98734845585101160448
}
/* Internal function to build a single 16-bit table - the table consists of
- * 'num' 256 entry subtables, where 'num' is determined by 'shift' - the amount
+ * 'num' 256-entry subtables, where 'num' is determined by 'shift' - the amount
* to shift the input values right (or 16-number_of_signifiant_bits).
*
* The caller is responsible for ensuring that the table gets cleaned up on
png_uint_16pp table = *ptable =
(png_uint_16pp)png_calloc(png_ptr, num * png_sizeof(png_uint_16p));
- /* 'num' is the number of tables and also the number of low bits of low
- * bits of the input 16-bit value used to select a table. Each table is
- * itself index by the high 8 bits of the value.
+ /* 'num' is the number of tables and also the number of low bits of the
+ * input 16-bit value used to select a table. Each table is itself indexed
+ * by the high 8 bits of the value.
*/
for (i = 0; i < num; i++)
table[i] = (png_uint_16p)png_malloc(png_ptr,
/* Build a single 8-bit table: same as the 16-bit case but much simpler (and
* typically much faster). Note that libpng currently does no sBIT processing
- * (apparently contrary to the spec) so a 256 entry table is always generated.
+ * (apparently contrary to the spec) so a 256-entry table is always generated.
*/
static void
png_build_8bit_table(png_structp png_ptr, png_bytepp ptable,
* Where 'iv' is the input color value and 'ov' is the output value -
* pow(iv, gamma).
*
- * Thus the gamma table consists of up to 256 256 entry tables. The table
+ * Thus the gamma table consists of up to 256 256-entry tables. The table
* is selected by the (8-gamma_shift) most significant of the low 8 bits of
* the color value then indexed by the upper 8 bits:
*