From f5703de28099ad0f60e50093f2f02b524a833e40 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Sun, 19 Apr 2009 06:20:57 -0500 Subject: [PATCH] Added -newtimestamp and -oldtimestamp options and deprecated -time_stamp option Default condition is -newtimestamp (output file will be timestamped with the time it was recompressed). If the -oldtimestamp option is used, the output file will be given the same timestamp as the input file, which was the default condition for recent versions of pngcrush. --- ChangeLog.txt | 9 +++++++++ pngcrush.c | 28 ++++++++++++++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 16a6f0540..afbbbb623 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,8 +1,17 @@ Change log: +Version 1.6.16 (built with libpng-1.2.35 and zlib-1.2.3.2) + Added -newtimestamp and -oldtimestamp options and changed + default condition to timestamping the output file with + the current time (i.e., -newtimestamp is default) + If the -oldtimestamp option is used then the output file + has the same timestamp as the input file. + Version 1.6.15 (built with libpng-1.2.35 and zlib-1.2.3.2) Fixes some missing typecasts on png_malloc() calls, patch from an anonymous reporter to the SourceForge bug tracker. + Added -time_stamp option to change time stamping from default + condition. Version 1.6.14 (built with libpng-1.2.35 and zlib-1.2.3.2) Avoids CVE-2009-0040. diff --git a/pngcrush.c b/pngcrush.c index 70111d701..88a23c522 100644 --- a/pngcrush.c +++ b/pngcrush.c @@ -26,7 +26,7 @@ * */ -#define PNGCRUSH_VERSION "1.6.15" +#define PNGCRUSH_VERSION "1.6.16" /* #define PNGCRUSH_COUNT_COLORS @@ -546,7 +546,7 @@ static int best_of_three; static int methods_specified = 0; static int intent = -1; static int ster_mode = -1; -static int new_time_stamp = 0; +static int new_time_stamp = 1; static int plte_len = -1; #ifdef PNG_FIXED_POINT_SUPPORTED static int specified_gamma = 0; @@ -1933,6 +1933,8 @@ int main(int argc, char *argv[]) /* no save; I just use this for testing decode speed */ nosave++; pngcrush_mode = EXTENSION_MODE; + } else if (!strncmp(argv[i], "-oldtimestamp", 5)) { + new_time_stamp=0; } else if (!strncmp(argv[i], "-plte_len", 9)) { names++; BUMP_I; @@ -2115,8 +2117,10 @@ int main(int argc, char *argv[]) #endif } } - else if (!strncmp(argv[i], "-time_stamp", 5)) - new_time_stamp++; + else if (!strncmp(argv[i], "-time_stamp", 5) || /* legacy */ + !strncmp(argv[i], "-newtimestamp", 5)) + new_time_stamp=1; + #ifdef PNG_tRNS_SUPPORTED else if (!strncmp(argv[i], "-trns_a", 7) || !strncmp(argv[i], "-tRNS_a", 7)) { @@ -5736,6 +5740,10 @@ struct options_help pngcrush_options[] = { {2, ""}, #endif + {0, " -newtimestamp"}, + {2, ""}, + {2, " Reset file modification time [default]."}, + {2, ""}, #ifdef PNGCRUSH_COUNT_COLORS {0, " -no_cc (no color counting)"}, @@ -5749,12 +5757,17 @@ struct options_help pngcrush_options[] = { {2, " ensuring that the input file is not the output file."}, {2, ""}, + + {0, " -oldtimestamp"}, + {2, ""}, + {2, " Don't reset file modification time."}, + {2, ""}, + {0, " -n (no save; does not do compression or write output PNG)"}, {2, ""}, {2, " Useful in conjunction with -v option to get info."}, {2, ""}, - {0, " -plte_len n (truncate PLTE)"}, {2, ""}, {2, " Truncates the PLTE. Be sure not to truncate it to"}, @@ -5839,11 +5852,6 @@ struct options_help pngcrush_options[] = { {2, " ten tEXt, iTXt, or zTXt chunks per pngcrush run."}, {2, ""}, - {0, " -time_stamp"}, - {2, ""}, - {2, " Reset file modification time."}, - {2, ""}, - #ifdef PNG_tRNS_SUPPORTED {0, " -trns_array n trns[0] trns[1] .. trns[n-1]"}, {2, ""},