Version in base suite: 2.3.0-13 Base version: pngcheck_2.3.0-13 Target version: pngcheck_3.0.3-1~deb11u1 Base file: /srv/ftp-master.debian.org/ftp/pool/main/p/pngcheck/pngcheck_2.3.0-13.dsc Target file: /srv/ftp-master.debian.org/policy/pool/main/p/pngcheck/pngcheck_3.0.3-1~deb11u1.dsc CHANGELOG | 46 ++ LICENSE | 23 + Makefile.mingw32 | 73 +++ Makefile.mingw64 | 73 +++ Makefile.unx | 6 README | 70 +-- debian/changelog | 76 +++ debian/clean | 6 debian/control | 2 debian/copyright | 16 debian/dirs | 1 debian/install | 6 debian/manpages | 3 debian/patches/010-makefile.patch | 47 ++ debian/patches/020-manpage_whatis.patch | 35 + debian/patches/10-pngsplit-format-strings.patch | 39 -- debian/patches/20-pngsplit-long-options.patch | 39 -- debian/patches/30-fix-new-source-warnings.patch | 43 -- debian/patches/40-fix-makefile-unx-dh.patch | 71 --- debian/patches/50-rename-makefile-unx.patch | 172 -------- debian/patches/60-fix-buffer-overflow.patch | 26 - debian/patches/series | 8 debian/png-fix-IDAT-windowsize.1.pod | 111 ----- debian/pngcheck.1.pod | 172 -------- debian/pngsplit.1.pod | 102 ----- debian/pod2man.mk | 69 --- debian/rules | 5 debian/tests/control | 3 debian/watch | 3 gpl/COPYING | 41 +- gpl/png-fix-IDAT-windowsize.1 | 27 + gpl/png-fix-IDAT-windowsize.c | 33 - gpl/pngsplit.1 | 28 + gpl/pngsplit.c | 22 - pngcheck.1 | 57 ++ pngcheck.c | 459 +++++++++++++++--------- 36 files changed, 897 insertions(+), 1116 deletions(-) diff -Nru pngcheck-2.3.0/CHANGELOG pngcheck-3.0.3/CHANGELOG --- pngcheck-2.3.0/CHANGELOG 2007-07-08 06:23:54.000000000 +0000 +++ pngcheck-3.0.3/CHANGELOG 2021-04-26 04:19:46.000000000 +0000 @@ -5,6 +5,7 @@ * * AL - Alexander Lehmann * AED - Andreas Dilger + * BB - Ben Beasley (Fedora Linux) * GRP - Glenn Randers-Pehrson * GRR - Greg Roelofs * JB - John Bowler @@ -218,3 +219,48 @@ * method; fixed non-verbose-mode IDAT/PLTE message * 20070707 GRR: released version 2.3.0 * ---------------------- + * 20070709 GRR: tweaked color definitions slightly to work better on terminals + * with white/light backgrounds + * 20070712 GRR: added Makefile.mingw32 + * 20100504 GRR: fixed DHDR (pre-MNG-1.0) bug identified by Winfried + * 20170713 GRP: added eXIf support (GRR: added check for II/MM/unknown format) + * 20201012 BB: converted static const help/usage-related strings to macros so + * -Werror=format-security doesn't trigger (Ben Beasley) + * 20201015 BB: added (help2man-generated) man pages for all three utils + * 20201017 GRR: added top-level LICENSE file; fixed various compiler warnings + * 20201031 GRR: replaced gpl/COPYING (outdated address, references to Library + * GPL) with https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt + * (thanks to Ben Beasley for catching that) + * 20201031 GRR: released version 2.4.0 + * ---------------------- + * 20201113 BB: fixed buffer-overflow vulnerability discovered by "giantbranch + * of NSFOCUS Security Team" + * https://bugzilla.redhat.com/show_bug.cgi?id=1897485 + * 20201128 BB: found and fixed four additional vulnerabilities (null-pointer + * dereference and three buffer overruns) + * 20201209 LP: fixed an off-by-one bug in check_magic() (Lucy Phipps) + * 20201209 LL: converted two zlib-version warnings/errors to go to stderr + * (Lemures Lemniscati, actually from 20180318; forwarded by LP) + * 20201210 BB: fixed another buffer-overflow vulnerability discovered by + * "giantbranch of NSFOCUS Security Team" + * https://bugzilla.redhat.com/show_bug.cgi?id=1905775 + * 20201212 GRR: removed -f ("force") option due to multiple security issues + * 20201212 GRR: released version 3.0.0 + * ---------------------- + * 20201214 BB: generalized previous sPLT buffer-overrun fix, and found and + * fixed a PPLT vulnerability + * 20210124 GRR: released version 3.0.1 + * ---------------------- + * 20201217 BB: fixed a crash bug (and probable vulnerability) in large (MNG) + * LOOP chunks + * 20210131 GRR: updated Makefile.mingw32 for modern versions and added + * Makefile.mingw64 (targets Win64); both are essentially + * UNTESTED, however! + * 20210131 GRR: released version 3.0.2 + * ---------------------- + * 20210416 BB: fixed a divide-by-zero crash bug (and probable vulnerability) + * in interlaced images with extra compressed data beyond the + * nominal end of the image data (found by "chiba of topsec alpha + * lab") + * 20210425 GRR: released version 3.0.3 + * ---------------------- diff -Nru pngcheck-2.3.0/LICENSE pngcheck-3.0.3/LICENSE --- pngcheck-2.3.0/LICENSE 1970-01-01 00:00:00.000000000 +0000 +++ pngcheck-3.0.3/LICENSE 2020-10-18 00:09:02.000000000 +0000 @@ -0,0 +1,23 @@ + Copyright 1995-2020 by Alexander Lehmann , + Andreas Dilger , + Glenn Randers-Pehrson , + Greg Roelofs , + John Bowler , + Tom Lane + + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose and without fee is hereby granted, provided + that the above copyright notice appear in all copies and that both that + copyright notice and this permission notice appear in supporting + documentation. This software is provided "as is" without express or + implied warranty. + + +[This license applies to pngcheck.c and its associated makefiles and + documentation in the main directory. The files in the "gpl" subdirectory-- + specifically, pngsplit.c and png-fix-IDAT-windowsize.c--are licensed under the + GNU General Public License. The files in "amiga" subdirectory are Copyright + 2003 Simon Goodwin and were contributed without an explicit license statement, + but insofar as the "gpl" subdirectory didn't exist at the time, it's safe to + assume their intended license was similar to pngcheck's, just with Simon's + copyright replacing the one above.] diff -Nru pngcheck-2.3.0/Makefile.mingw32 pngcheck-3.0.3/Makefile.mingw32 --- pngcheck-2.3.0/Makefile.mingw32 1970-01-01 00:00:00.000000000 +0000 +++ pngcheck-3.0.3/Makefile.mingw32 2021-01-31 21:51:22.000000000 +0000 @@ -0,0 +1,73 @@ +# Sample makefile for pngcheck using mingw32-gcc (native or cross) and make. +# This one is currently set up for Win32 cross-compilation from Linux. +# +# Greg Roelofs +# Last modified: 31 January 2021 +# +# Invoke this makefile from a DOS-prompt window or xterm or whatever via: +# +# make -f Makefile.mingw32 +# +# This makefile assumes zlib has already been built or downloaded and is in +# a subdirectory at the same level as the current subdirectory (as indicated +# by the ZPATH macro below). Edit as appropriate. +# +# Note that the names of the dynamic and static zlib libraries used below may +# change in later releases of the library. This makefile builds statically +# linked executables, but that can be changed by uncommenting the appropriate +# ZLIB line. + + +# macros -------------------------------------------------------------------- + +#ZPATH = ../zlib +ZPATH = ../zlib-1.2.11-win32 +ZINC = -I$(ZPATH) +#ZLIB = $(ZPATH)/libzdll.a # link dynamically against DLL +ZLIB = $(ZPATH)/libz.a # link statically + +INCS = $(ZINC) +LIBS = $(ZLIB) + +#CC = gcc +CC = i686-w64-mingw32-gcc # Linux -> Win32 cross-compilation +LD = $(CC) +RM = rm -f +CFLAGS = -O -Wall $(INCS) $(MINGW_CCFLAGS) -DUSE_ZLIB +# [note that -Wall is a gcc-specific compilation flag ("most warnings on")] +LDFLAGS = $(MINGW_LDFLAGS) +O = .o +E = .win32.exe + +PROG = pngcheck +PROG2 = pngsplit +PROG3 = png-fix-IDAT-windowsize + +EXES = $(PROG)$(E) $(PROG2)$(E) $(PROG3)$(E) + + +# implicit make rules ------------------------------------------------------- + +.c$(O): + $(CC) -c $(CFLAGS) $< + + +# dependencies -------------------------------------------------------------- + +all: $(EXES) + +$(PROG)$(E): $(PROG).c + $(CC) $(CFLAGS) -o $@ $(PROG).c $(LIBS) + +# both of these require zlib, too (for crc32() function) +$(PROG2)$(E): gpl/$(PROG2).c + $(CC) $(CFLAGS) -o $@ gpl/$(PROG2).c $(LIBS) + +$(PROG3)$(E): gpl/$(PROG3).c + $(CC) $(CFLAGS) -o $@ gpl/$(PROG3).c $(LIBS) + + +# maintenance --------------------------------------------------------------- + +clean: + $(RM) $(EXES) diff -Nru pngcheck-2.3.0/Makefile.mingw64 pngcheck-3.0.3/Makefile.mingw64 --- pngcheck-2.3.0/Makefile.mingw64 1970-01-01 00:00:00.000000000 +0000 +++ pngcheck-3.0.3/Makefile.mingw64 2021-01-31 21:53:47.000000000 +0000 @@ -0,0 +1,73 @@ +# Sample makefile for pngcheck using mingw32-gcc (native or cross) and make. +# This one is currently set up for Win64 cross-compilation from Linux. +# +# Greg Roelofs +# Last modified: 31 January 2021 +# +# Invoke this makefile from a DOS-prompt window or xterm or whatever via: +# +# make -f Makefile.mingw64 +# +# This makefile assumes zlib has already been built or downloaded and is in +# a subdirectory at the same level as the current subdirectory (as indicated +# by the ZPATH macro below). Edit as appropriate. +# +# Note that the names of the dynamic and static zlib libraries used below may +# change in later releases of the library. This makefile builds statically +# linked executables, but that can be changed by uncommenting the appropriate +# ZLIB line. + + +# macros -------------------------------------------------------------------- + +#ZPATH = ../zlib +ZPATH = ../zlib-1.2.11-win64 +ZINC = -I$(ZPATH) +#ZLIB = $(ZPATH)/libzdll.a # link dynamically against DLL +ZLIB = $(ZPATH)/libz.a # link statically + +INCS = $(ZINC) +LIBS = $(ZLIB) + +#CC = gcc +CC = x86_64-w64-mingw32-gcc # Linux -> Win64 cross-compilation +LD = $(CC) +RM = rm -f +CFLAGS = -O -Wall $(INCS) $(MINGW_CCFLAGS) -DUSE_ZLIB +# [note that -Wall is a gcc-specific compilation flag ("most warnings on")] +LDFLAGS = $(MINGW_LDFLAGS) +O = .o +E = .win64.exe + +PROG = pngcheck +PROG2 = pngsplit +PROG3 = png-fix-IDAT-windowsize + +EXES = $(PROG)$(E) $(PROG2)$(E) $(PROG3)$(E) + + +# implicit make rules ------------------------------------------------------- + +.c$(O): + $(CC) -c $(CFLAGS) $< + + +# dependencies -------------------------------------------------------------- + +all: $(EXES) + +$(PROG)$(E): $(PROG).c + $(CC) $(CFLAGS) -o $@ $(PROG).c $(LIBS) + +# both of these require zlib, too (for crc32() function) +$(PROG2)$(E): gpl/$(PROG2).c + $(CC) $(CFLAGS) -o $@ gpl/$(PROG2).c $(LIBS) + +$(PROG3)$(E): gpl/$(PROG3).c + $(CC) $(CFLAGS) -o $@ gpl/$(PROG3).c $(LIBS) + + +# maintenance --------------------------------------------------------------- + +clean: + $(RM) $(EXES) diff -Nru pngcheck-2.3.0/Makefile.unx pngcheck-3.0.3/Makefile.unx --- pngcheck-2.3.0/Makefile.unx 2006-06-17 22:47:35.000000000 +0000 +++ pngcheck-3.0.3/Makefile.unx 2020-10-18 00:40:27.000000000 +0000 @@ -1,6 +1,6 @@ # gcc/gmake makefile for pngcheck. # Greg Roelofs -# Last modified: 17 June 2006 +# Last modified: 17 October 2020 # # Invoke via: # @@ -20,8 +20,8 @@ ZPATH = ../zlib ZINC = -I$(ZPATH) -#ZLIB = -L$(ZPATH) -lz -ZLIB = $(ZPATH)/libz.a +ZLIB = -L$(ZPATH) -lz +#ZLIB = $(ZPATH)/libz.a INCS = $(ZINC) LIBS = $(ZLIB) diff -Nru pngcheck-2.3.0/README pngcheck-3.0.3/README --- pngcheck-2.3.0/README 2007-07-08 06:37:37.000000000 +0000 +++ pngcheck-3.0.3/README 2021-04-26 04:27:42.000000000 +0000 @@ -1,25 +1,19 @@ -pngcheck version 2.3.0 of 7 July 2007 +pngcheck version 3.0.3 of 25 April 2021 -This version adds a new ANSI-colorized-output option (probably optimized for -dark-background xterms) and more informative output for interlaced images, -such as: - - chunk IDAT at offset 0x000e1, length 8119 - zlib: deflated, 32K window, default compression - rows per pass: 9, 9, 9, 18, 17, 35, 34 // new summary line - row filters (0 none, 1 sub, 2 up, 3 avg, 4 paeth): - 0 0 2 4 2 2 4 0 0 | 0 0 3 1 4 4 2 0 2 | 0 4 2 2 2 // vertical bars - 2 2 0 0 | 0 0 2 2 2 2 2 2 2 2 2 2 2 2 4 2 0 0 | 0 // separate passes - 1 4 1 4 4 1 2 2 2 2 2 1 4 2 1 1 | 0 0 0 4 3 2 4 2 - 4 2 4 1 2 4 2 2 2 2 2 4 2 2 2 2 2 2 2 4 2 2 2 4 4 - 4 0 | 0 0 4 4 3 1 4 4 4 4 4 1 1 4 4 3 2 2 3 3 2 3 - 3 3 1 4 1 4 2 4 4 1 3 1 (131 out of 131) - -It also detects two more of the warning/error cases in brokensuite-20061204, -bringing the total to 112 of the 114 files, and it fixes some minor problems -with the output of some of the other cases. In addition, pngsplit now sup- -ports MNG and JNG files, as originally claimed but not actually implemented -(oops...). +This version fixes another (probable) security vulnerability discovered by +"chiba of topsec alpha lab". Ben Beasley of the Fedora Linux project fixed +it, and I generalized it a bit to forestall other attempts by the code to +keep decoding beyond the declared image dimensions. As always, many thanks +to Ben and to the various security researchers who continue to ferret out +problematic code. + +I've also updated the MinGW32 cross-compiler makefile for both Win32 and Win64 +targets (i.e., there are two such makefiles now), but other than verifying +that binaries come out the other end, these are COMPLETELY UNTESTED. In +particular, the printf() format "%td" for ptrdiff_t (pointer differences, i.e., +subtraction) doesn't appear to be supported under Windows, but I don't know +what the appropriate type is. So the five affected print statements presumably +just won't work correctly. Here's a list of the major enhancements since version 1.98, which was the last release before I took over maintenance: @@ -30,7 +24,7 @@ - complete support for all known MNG and JNG chunks (informational) - extended support for printing palettes (includes transparency info and histograms) - - color support + - optional color (text) output - improved error-checking - info on the compression factor of the image (expressed as a percentage, where 0% is no compression and 100% would be total compression; note that @@ -40,11 +34,16 @@ - pngsplit utility - compilation support for Win32 (using MSVC), RISC OS, and Amiga +Also, this "anti-enhancement" occurred in version 3.0.0 for security reasons: + + - -f ("force continuation after major errors") option REMOVED + There are also many fixes, of course, including ones from Tom Lane, Glenn Randers-Pehrson, Tom Zerucha, Paul Matzke, Darren Salt, John Bowler, and others. Thanks also to Chris Nokleberg (brokensuite), Tim Pritlove, Bob -Friesenhahn, the GraalOnline folks, and others for test images. See the -included CHANGELOG file for the complete, detailed list of who did what. +Friesenhahn, the GraalOnline folks, giantbranch, chiba, Ben Beasley, and +others for test images. See the included CHANGELOG file for the complete, +detailed list of who did what. Note that while MNG support is now complete in the sense of covering all registered chunk types, there are still numerous error conditions that @@ -59,14 +58,21 @@ zlib 1.2.x for best results--older versions failed to detect a number of invalid deflate/zlib conditions, including out-of-range LZ77 distance codes. -I still hope to add support for EBCDIC-based systems (and perhaps UTF-16 -and UTF-32-based ones, if there are any for which "char" defaults to more -than 8 bits) someday, and the zlib support should be extended to include -zTXt, iTXt, iCCP, etc. The code could also do a better job with chunks -whose data exceed the buffer size; and in general, immense if-else blocks -(e.g., > 3000 lines) are fairly nasty and should be rewritten. Someday... +Originally I had hoped to add support for EBCDIC-based systems (and perhaps +UTF-16 and UTF-32-based ones, if there are any for which "char" defaults to +more than 8 bits), but there doesn't seem to be much point in that anymore. +I'd still kind of like to extend the zlib support to include zTXt, iTXt, iCCP, +etc., but given the pace of recent years ("nonexistent" would be fair), folks +should definitely not hold their breath waiting for that. Similarly, the code +could do a better job with chunks whose data exceed the buffer size, and in +general, immense if-else blocks (e.g., > 3000 lines) are extremely nasty and +should be rewritten, but...yeah. The gap between 2.3.0 and 2.4.0 (the two +previous releases) was bigger than that between 2.3.0 and the creation of the +PNG format itself. :-/ (Did we mention that PNG turned 25 in 2020?) + +But if there ever are additional updates, you might find them here: -As always, see http://www.libpng.org/pub/png/apps/pngcheck.html for updates. + http://www.libpng.org/pub/png/apps/pngcheck.html Greg Roelofs -http://pobox.com/~newt/greg_contact.html +http://gregroelofs.com/greg_contact.html diff -Nru pngcheck-2.3.0/debian/changelog pngcheck-3.0.3/debian/changelog --- pngcheck-2.3.0/debian/changelog 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/changelog 2022-12-09 15:56:59.000000000 +0000 @@ -1,3 +1,79 @@ +pngcheck (3.0.3-1~deb11u1) bullseye-security; urgency=medium + + * Rebuild for stable, pretty much all of the changes since 2.3.0 + are security fixes, besides CVE-2020-35511, there's also several + without CVE IDs assigned. Upstream dropped the -f option as a + security fix, as such it's also missing in this upload (Closes: #1021278) + + -- Moritz Fri, 09 Dec 2022 17:54:41 +0100 + +pngcheck (3.0.3-1) unstable; urgency=medium + + * New upstream version 3.0.3. (Closes: #1021278, LP: #1960400) + * debian/patches/020-manpage_whatis.patch: fixed to reflect upstream changes. + + -- David da Silva Polverari Mon, 05 Dec 2022 20:08:12 +0000 + +pngcheck (3.0.2-4) unstable; urgency=medium + + * debian/watch: changed the download URL to the homepage as the previous one + only hosts the Win32 source zip. + + -- David da Silva Polverari Mon, 05 Dec 2022 10:52:05 -0300 + +pngcheck (3.0.2-3) unstable; urgency=medium + + * debian/control: bumped Standards-Version to 4.6.1. + * debian/copyright: updated packaging copyright years. + * debian/tests/control: changed test to avoid failing only because of warning. + Thanks to Paul Gevers . (Closes: #1024180) + + -- David da Silva Polverari Thu, 24 Nov 2022 15:14:37 +0000 + +pngcheck (3.0.2-2) unstable; urgency=medium + + * Upload to unstable. + * debian/control: bumped Standards-Version to 4.6.0. + * debian/rules: avoided FTCBFS by explicitly passing CC to make. + + -- David da Silva Polverari Sun, 26 Sep 2021 22:56:24 +0000 + +pngcheck (3.0.2-1) experimental; urgency=medium + + * New upstream version 3.0.2. + * debian/clean: updated to reflect the changes in the makefile patch. + * debian/control: bumped Standards-Version to 4.5.1. + * debian/copyright: updated upstream and packaging copyright years. + * debian/dirs: no longer needed, as debian/install creates every needed + directory. Removed. + * debian/install: updated to reflect changes in the makefile patch. + * debian/manpages: updated to install upstream-provided manpages. + * debian/patches/: + - 010-makefile.patch: added to replace previous makefile patch and + minimize changes from upstream. + - 020-manpage_whatis.patch: added to provide more useful whatis entries + for upstream manpages. + - 10-pngsplit-format-strings.patch and 30-fix-new-source-warnings.patch: + no longer needed, as the previously affected upstream function calls now + use string literals instead of variables. Removed. + - 20-pngsplit-long-options.patch: removed, as it changes upstream + command-line interface for no good reason. + - 40-fix-makefile-unx-dh.patch: replaced by 010-makefile.patch. + - 50-rename-makefile-unx.patch: no longer needed, because of added + dh_auto_build override in debian/rules. Removed. + - 60-fix-buffer-overflow.patch: no longer needed, as new upstream version + already contains it. Removed. + * debian/pod2man.mk: no longer needed, as there are no *.pod files left. + Removed. + * debian/rules: + - Added dh_auto_build override to use non-standard makefile name. + - Removed export '-Wl,--as-needed' linker flag, as the bullseye toolchain + defaults to linking with it. + * debian/*.pod: no longer needed, as upstream now provides manpages to all + binaries. Removed. + + -- David da Silva Polverari Tue, 08 Jun 2021 02:55:39 +0000 + pngcheck (2.3.0-13) unstable; urgency=medium * debian/patches/60-fix-buffer-overflow.patch: added to fix CVE-2020-27818. diff -Nru pngcheck-2.3.0/debian/clean pngcheck-3.0.3/debian/clean --- pngcheck-2.3.0/debian/clean 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/clean 2022-10-07 23:44:44.000000000 +0000 @@ -1,4 +1,4 @@ -pngcheck -gpl/pngsplit -gpl/png-fix-IDAT-windowsize debian/*.1 +pngcheck +png-fix-IDAT-windowsize +pngsplit diff -Nru pngcheck-2.3.0/debian/control pngcheck-3.0.3/debian/control --- pngcheck-2.3.0/debian/control 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/control 2022-11-24 14:45:26.000000000 +0000 @@ -3,7 +3,7 @@ Priority: optional Maintainer: David da Silva Polverari Build-Depends: debhelper-compat (= 13), zlib1g-dev -Standards-Version: 4.5.0 +Standards-Version: 4.6.1 Rules-Requires-Root: no Vcs-Browser: https://salsa.debian.org/debian/pngcheck Vcs-Git: https://salsa.debian.org/debian/pngcheck.git diff -Nru pngcheck-2.3.0/debian/copyright pngcheck-3.0.3/debian/copyright --- pngcheck-2.3.0/debian/copyright 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/copyright 2022-11-24 14:47:45.000000000 +0000 @@ -5,17 +5,17 @@ Comment: upstream's personal homepage is at http://www.gregroelofs.com Files: * -Copyright: 1995-2007 Alexander Lehmann - 1995-2007 Andreas Dilger - 1995-2007 Glenn Randers-Pehrson - 1995-2007 Greg Roelofs - 1995-2007 John Bowler - 1995-2007 Tom Lane +Copyright: 1995-2021 Alexander Lehmann + 1995-2021 Andreas Dilger + 1995-2021 Glenn Randers-Pehrson + 1995-2021 Greg Roelofs + 1995-2021 John Bowler + 1995-2021 Tom Lane License: Custom-MIT-like Files: gpl/png-fix-IDAT-windowsize.c gpl/pngsplit.c -Copyright: 2005-2006 Greg Roelofs +Copyright: 2005-2020 Greg Roelofs License: GPL-2+ Files: debian/* @@ -23,7 +23,7 @@ 2005-2006 Lucas Wall 2008-2013 Jari Aalto 2008 Marco Rodrigues - 2020 David da Silva Polverari + 2020-2022 David da Silva Polverari License: GPL-2+ Files: debian/tests/openlogo-nd-100.png diff -Nru pngcheck-2.3.0/debian/dirs pngcheck-3.0.3/debian/dirs --- pngcheck-2.3.0/debian/dirs 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/dirs 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -usr/bin diff -Nru pngcheck-2.3.0/debian/install pngcheck-3.0.3/debian/install --- pngcheck-2.3.0/debian/install 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/install 2022-10-07 23:44:44.000000000 +0000 @@ -1,3 +1,3 @@ -gpl/png-fix-IDAT-windowsize usr/bin -gpl/pngsplit usr/bin -pngcheck usr/bin +png-fix-IDAT-windowsize usr/bin +pngcheck usr/bin +pngsplit usr/bin diff -Nru pngcheck-2.3.0/debian/manpages pngcheck-3.0.3/debian/manpages --- pngcheck-2.3.0/debian/manpages 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/manpages 2022-10-07 23:44:44.000000000 +0000 @@ -1 +1,2 @@ -debian/*.1 +*.1 +gpl/*.1 diff -Nru pngcheck-2.3.0/debian/patches/010-makefile.patch pngcheck-3.0.3/debian/patches/010-makefile.patch --- pngcheck-2.3.0/debian/patches/010-makefile.patch 1970-01-01 00:00:00.000000000 +0000 +++ pngcheck-3.0.3/debian/patches/010-makefile.patch 2022-10-07 23:44:44.000000000 +0000 @@ -0,0 +1,47 @@ +Description: fix makefile for dh usage +Author: David da Silva Polverari +Forwarded: not-needed +Last-Update: 2021-06-07 + +--- a/Makefile.unx ++++ b/Makefile.unx +@@ -23,18 +23,18 @@ + ZLIB = -L$(ZPATH) -lz + #ZLIB = $(ZPATH)/libz.a + +-INCS = $(ZINC) ++INCS = + LIBS = $(ZLIB) + +-CC = gcc ++#CC = gcc + LD = gcc + RM = rm +-CFLAGS = -O -Wall $(INCS) -DUSE_ZLIB ++CFLAGS += -O $(INCS) -DUSE_ZLIB + # [note that -Wall is a gcc-specific compilation flag ("all warnings on")] + O = .o + E = + +-LDFLAGS = ++LDFLAGS += + + PROG = pngcheck + PROG2 = pngsplit +@@ -57,13 +57,13 @@ + all: $(EXES) + + $(PROG)$(E): $(PROG).c +- $(CC) $(CFLAGS) -o $@ $(PROG).c $(LIBS) ++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $(PROG).c $(LIBS) + + $(PROG2)$(E): gpl/$(PROG2).c +- $(CC) $(CFLAGS) -o $@ gpl/$(PROG2).c $(LIBS) ++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ gpl/$(PROG2).c $(LIBS) + + $(PROG3)$(E): gpl/$(PROG3).c +- $(CC) $(CFLAGS) -o $@ gpl/$(PROG3).c $(LIBS) ++ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ gpl/$(PROG3).c $(LIBS) + + + # maintenance --------------------------------------------------------------- diff -Nru pngcheck-2.3.0/debian/patches/020-manpage_whatis.patch pngcheck-3.0.3/debian/patches/020-manpage_whatis.patch --- pngcheck-2.3.0/debian/patches/020-manpage_whatis.patch 1970-01-01 00:00:00.000000000 +0000 +++ pngcheck-3.0.3/debian/patches/020-manpage_whatis.patch 2022-12-05 19:46:38.000000000 +0000 @@ -0,0 +1,35 @@ +Description: provide useful whatis fields for the manpages +Author: David da Silva Polverari +Forwarded: newt@pobox.com +Last-Update: 2022-12-05 + +--- a/pngcheck.1 ++++ b/pngcheck.1 +@@ -1,6 +1,6 @@ + .TH PNGCHECK "1" "April 2021" "pngcheck 3.0.3" "User Commands" + .SH NAME +-pngcheck \- manual page for pngcheck 3.0.3 ++pngcheck \- tests PNG, JNG or MNG image files for corruption, and prints size/type info. + .SH SYNOPSIS + .B pngcheck + .RI [ \-7cpqtv ] +--- a/gpl/pngsplit.1 ++++ b/gpl/pngsplit.1 +@@ -1,6 +1,6 @@ + .TH PNGSPLIT "1" "October 2020" "pngsplit 1.0" "User Commands" + .SH NAME +-pngsplit \- manual page for pngsplit 1.0 ++pngsplit \- splits a PNG, MNG or JNG file into individual, numbered chunks. + .SH SYNOPSIS + .B pngsplit + .RI [ options ] +--- a/gpl/png-fix-IDAT-windowsize.1 ++++ b/gpl/png-fix-IDAT-windowsize.1 +@@ -1,6 +1,6 @@ + .TH PNG-FIX-IDAT-WINDOWSIZE "1" "October 2020" "png-fix-IDAT-windowsize 1.0" "User Commands" + .SH NAME +-png-fix-IDAT-windowsize \- manual page for png-fix-IDAT-windowsize 1.0 ++png-fix-IDAT-windowsize \- utility to reset first IDAT's zlib window-size bytes and fix up CRC to match. + .SH SYNOPSIS + .B png\-fix\-IDAT\-windowsize + .RI [ options ] diff -Nru pngcheck-2.3.0/debian/patches/10-pngsplit-format-strings.patch pngcheck-3.0.3/debian/patches/10-pngsplit-format-strings.patch --- pngcheck-2.3.0/debian/patches/10-pngsplit-format-strings.patch 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/patches/10-pngsplit-format-strings.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -From: Jari Aalto -Subject: Correct format strings for hardened build flags ---- - gpl/pngsplit.c | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - ---- a/gpl/pngsplit.c -+++ b/gpl/pngsplit.c -@@ -141,8 +141,8 @@ - 0 == strncmp( argv[argn], "-quiet", 2 ) ) - verbose = 0; - else { -- fprintf(stderr, pngsplit_hdr); -- fprintf(stderr, pngsplit_usage); -+ fprintf(stderr, "%s", pngsplit_hdr); -+ fprintf(stderr, "%s", pngsplit_usage); - fflush(stderr); - return 1; - } -@@ -150,8 +150,8 @@ - } - - if ( argn == argc ) { -- fprintf(stderr, pngsplit_hdr); -- fprintf(stderr, pngsplit_usage); -+ fprintf(stderr, "%s", pngsplit_hdr); -+ fprintf(stderr, "%s", pngsplit_usage); - fflush(stderr); - return 5; - } else { -@@ -162,7 +162,7 @@ - - /*============================= MAIN LOOP =============================*/ - -- fprintf(stdout, pngsplit_hdr); -+ fprintf(stdout, "%s", pngsplit_hdr); - fflush(stdout); - - while (argn <= argc) { diff -Nru pngcheck-2.3.0/debian/patches/20-pngsplit-long-options.patch pngcheck-3.0.3/debian/patches/20-pngsplit-long-options.patch --- pngcheck-2.3.0/debian/patches/20-pngsplit-long-options.patch 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/patches/20-pngsplit-long-options.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -From: Jari Aalto -Subject: Use GNU --long option syntax ---- - gpl/pngsplit.c | 15 ++++++++------- - 1 file changed, 8 insertions(+), 7 deletions(-) - ---- a/gpl/pngsplit.c -+++ b/gpl/pngsplit.c -@@ -86,8 +86,9 @@ - static const char *pngsplit_usage = "\ - usage: pngsplit [options] pngfile [pngfile [...]]\n\ - options:\n\ -- -force overwrite existing output files\n\ -- -verbose print more status messages (synonym: -noquiet)\n\n\ -+ --force Overwrite existing output files\n\ -+ --quiet Be quiet\n\ -+ --verbose Display more status messages\n\n\ - Split a PNG, MNG or JNG file into individual, numbered chunks (filenames\n\ - \"foo.png.0000.sig\", \"foo.png.0001.IHDR\", etc.).\n"; - -@@ -132,13 +133,13 @@ - while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { - if ( 0 == strncmp( argv[argn], "-force", 2 ) ) - force = TRUE; -- else if ( 0 == strncmp( argv[argn], "-noforce", 4 ) ) -+ else if ( 0 == strncmp( argv[argn], "--noforce", 4 ) ) - force = FALSE; -- else if ( 0 == strncmp( argv[argn], "-verbose", 2 ) || -- 0 == strncmp( argv[argn], "-noquiet", 4 ) ) -+ else if ( 0 == strncmp( argv[argn], "--verbose", 2 ) || -+ 0 == strncmp( argv[argn], "--noquiet", 4 ) ) - ++verbose; -- else if ( 0 == strncmp( argv[argn], "-noverbose", 4 ) || -- 0 == strncmp( argv[argn], "-quiet", 2 ) ) -+ else if ( 0 == strncmp( argv[argn], "--noverbose", 4 ) || -+ 0 == strncmp( argv[argn], "--quiet", 2 ) ) - verbose = 0; - else { - fprintf(stderr, "%s", pngsplit_hdr); diff -Nru pngcheck-2.3.0/debian/patches/30-fix-new-source-warnings.patch pngcheck-3.0.3/debian/patches/30-fix-new-source-warnings.patch --- pngcheck-2.3.0/debian/patches/30-fix-new-source-warnings.patch 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/patches/30-fix-new-source-warnings.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -Description: fix the warnings caused by previously unused source file - This patch fixes the "format string" and "unused return value" warnings caused - by the inclusion of gpl/png-fix-IDAT-windowsize.c as a make target on - debian/rules. -Author: David da Silva Polverari -Last-Update: 2020-05-27 ---- a/gpl/png-fix-IDAT-windowsize.c -+++ b/gpl/png-fix-IDAT-windowsize.c -@@ -127,7 +127,7 @@ - fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", - ZLIB_VERSION, zlib_version); - fprintf(stderr, "\n"); -- fprintf(stderr, png_fix_IDAT_windowsize_usage); -+ fprintf(stderr, "%s", png_fix_IDAT_windowsize_usage); - fflush(stderr); - return 1; - } -@@ -143,7 +143,7 @@ - fflush(stdout); - - if ( argn == argc ) { -- fprintf(stderr, png_fix_IDAT_windowsize_usage); -+ fprintf(stderr, "%s", png_fix_IDAT_windowsize_usage); - fflush(stderr); - return 5; - } else { -@@ -202,6 +202,7 @@ - - static int png_fix_IDAT_windowsize(char *filename, int force, int verbose) - { -+ size_t num_read; - FILE *infile, *outfile; - uch inbuf[BUFSZ], *inptr, *endptr; - uch *cbuf=NULL, *cptr; -@@ -532,7 +533,7 @@ - cptr = cbuf; - csize = csize_orig; - -- fread(cbuf, 1, chunklen+12, infile); -+ num_read = fread(cbuf, 1, chunklen+12, infile); - - calc_crc = crc32(0L, Z_NULL, 0); - calc_crc = crc32(calc_crc, cbuf+4, chunklen+4); diff -Nru pngcheck-2.3.0/debian/patches/40-fix-makefile-unx-dh.patch pngcheck-3.0.3/debian/patches/40-fix-makefile-unx-dh.patch --- pngcheck-2.3.0/debian/patches/40-fix-makefile-unx-dh.patch 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/patches/40-fix-makefile-unx-dh.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -Description: fixes the upstream Makefile to work with debhelper - This patch fixes the upstream file Makefile.unx to make it work with dh as - used by a standard debian/rules file. It works in conjunction with the next - patch in the series to rename the Makefile for dh consumption. -Author: David da Silva Polverari -Last-Update: 2020-05-29 ---- a/Makefile.unx -+++ b/Makefile.unx -@@ -18,23 +18,23 @@ - - # macros -------------------------------------------------------------------- - --ZPATH = ../zlib --ZINC = -I$(ZPATH) -+#ZPATH = ../zlib -+#ZINC = -I$(ZPATH) - #ZLIB = -L$(ZPATH) -lz --ZLIB = $(ZPATH)/libz.a -+ZLIB = -lz - --INCS = $(ZINC) -+INCS = - LIBS = $(ZLIB) - --CC = gcc -+#CC = gcc - LD = gcc - RM = rm --CFLAGS = -O -Wall $(INCS) -DUSE_ZLIB -+CFLAGS += -O $(INCS) -DUSE_ZLIB - # [note that -Wall is a gcc-specific compilation flag ("all warnings on")] - O = .o - E = - --LDFLAGS = -+LDFLAGS += - - PROG = pngcheck - PROG2 = pngsplit -@@ -54,19 +54,27 @@ - - # dependencies -------------------------------------------------------------- - --all: $(EXES) -+all: $(EXES) man - - $(PROG)$(E): $(PROG).c -- $(CC) $(CFLAGS) -o $@ $(PROG).c $(LIBS) -+ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $(PROG).c $(LIBS) - - $(PROG2)$(E): gpl/$(PROG2).c -- $(CC) $(CFLAGS) -o $@ gpl/$(PROG2).c $(LIBS) -+ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o gpl/$@ gpl/$(PROG2).c $(LIBS) - - $(PROG3)$(E): gpl/$(PROG3).c -- $(CC) $(CFLAGS) -o $@ gpl/$(PROG3).c $(LIBS) -+ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o gpl/$@ gpl/$(PROG3).c $(LIBS) - - - # maintenance --------------------------------------------------------------- - - clean: - $(RM) -f $(EXES) $(OBJS) -+ -+# man pages generation ------------------------------------------------------ -+man: -+ $(MAKE) -C debian -f pod2man.mk PACKAGE=$(PROG) makeman -+ $(MAKE) -C debian -f pod2man.mk PACKAGE=$(PROG2) makeman -+ $(MAKE) -C debian -f pod2man.mk PACKAGE=$(PROG3) makeman -+ -+.PHONY: man diff -Nru pngcheck-2.3.0/debian/patches/50-rename-makefile-unx.patch pngcheck-3.0.3/debian/patches/50-rename-makefile-unx.patch --- pngcheck-2.3.0/debian/patches/50-rename-makefile-unx.patch 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/patches/50-rename-makefile-unx.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ -Description: rename Makefile.unx to Makefile - This patch renames the Makefile.unx file to Makefile after the previous patch - was applied, for DH to use it by default. This fix was split into two patches - to work around quilt limitations on representing diffs for a renamed file. -Author: David da Silva Polverari -Last-Update: 2020-05-29 ---- /dev/null -+++ b/Makefile -@@ -0,0 +1,80 @@ -+# gcc/gmake makefile for pngcheck. -+# Greg Roelofs -+# Last modified: 17 June 2006 -+# -+# Invoke via: -+# -+# make -f Makefile.unx -+# -+# This makefile assumes zlib has already been built or downloaded and is in -+# a subdirectory at the same level as the current subdirectory (as indicated -+# by the ZPATH macro below). Edit as appropriate. -+# -+# Note that the names of the dynamic and static zlib libraries used below may -+# change in later releases of the library. This makefile builds statically -+# linked executables, but that can be changed by uncommenting the appropriate -+# ZLIB lines. -+ -+ -+# macros -------------------------------------------------------------------- -+ -+#ZPATH = ../zlib -+#ZINC = -I$(ZPATH) -+#ZLIB = -L$(ZPATH) -lz -+ZLIB = -lz -+ -+INCS = -+LIBS = $(ZLIB) -+ -+#CC = gcc -+LD = gcc -+RM = rm -+CFLAGS += -O $(INCS) -DUSE_ZLIB -+# [note that -Wall is a gcc-specific compilation flag ("all warnings on")] -+O = .o -+E = -+ -+LDFLAGS += -+ -+PROG = pngcheck -+PROG2 = pngsplit -+PROG3 = png-fix-IDAT-windowsize -+ -+#OBJS = $(PROG)$(O) -+OBJS = -+ -+EXES = $(PROG)$(E) $(PROG2)$(E) $(PROG3)$(E) -+ -+ -+# implicit make rules ------------------------------------------------------- -+ -+.c$(O): -+ $(CC) -c $(CFLAGS) $< -+ -+ -+# dependencies -------------------------------------------------------------- -+ -+all: $(EXES) man -+ -+$(PROG)$(E): $(PROG).c -+ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $(PROG).c $(LIBS) -+ -+$(PROG2)$(E): gpl/$(PROG2).c -+ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o gpl/$@ gpl/$(PROG2).c $(LIBS) -+ -+$(PROG3)$(E): gpl/$(PROG3).c -+ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o gpl/$@ gpl/$(PROG3).c $(LIBS) -+ -+ -+# maintenance --------------------------------------------------------------- -+ -+clean: -+ $(RM) -f $(EXES) $(OBJS) -+ -+# man pages generation ------------------------------------------------------ -+man: -+ $(MAKE) -C debian -f pod2man.mk PACKAGE=$(PROG) makeman -+ $(MAKE) -C debian -f pod2man.mk PACKAGE=$(PROG2) makeman -+ $(MAKE) -C debian -f pod2man.mk PACKAGE=$(PROG3) makeman -+ -+.PHONY: man ---- a/Makefile.unx -+++ /dev/null -@@ -1,80 +0,0 @@ --# gcc/gmake makefile for pngcheck. --# Greg Roelofs --# Last modified: 17 June 2006 --# --# Invoke via: --# --# make -f Makefile.unx --# --# This makefile assumes zlib has already been built or downloaded and is in --# a subdirectory at the same level as the current subdirectory (as indicated --# by the ZPATH macro below). Edit as appropriate. --# --# Note that the names of the dynamic and static zlib libraries used below may --# change in later releases of the library. This makefile builds statically --# linked executables, but that can be changed by uncommenting the appropriate --# ZLIB lines. -- -- --# macros -------------------------------------------------------------------- -- --#ZPATH = ../zlib --#ZINC = -I$(ZPATH) --#ZLIB = -L$(ZPATH) -lz --ZLIB = -lz -- --INCS = --LIBS = $(ZLIB) -- --#CC = gcc --LD = gcc --RM = rm --CFLAGS += -O $(INCS) -DUSE_ZLIB --# [note that -Wall is a gcc-specific compilation flag ("all warnings on")] --O = .o --E = -- --LDFLAGS += -- --PROG = pngcheck --PROG2 = pngsplit --PROG3 = png-fix-IDAT-windowsize -- --#OBJS = $(PROG)$(O) --OBJS = -- --EXES = $(PROG)$(E) $(PROG2)$(E) $(PROG3)$(E) -- -- --# implicit make rules ------------------------------------------------------- -- --.c$(O): -- $(CC) -c $(CFLAGS) $< -- -- --# dependencies -------------------------------------------------------------- -- --all: $(EXES) man -- --$(PROG)$(E): $(PROG).c -- $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $(PROG).c $(LIBS) -- --$(PROG2)$(E): gpl/$(PROG2).c -- $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o gpl/$@ gpl/$(PROG2).c $(LIBS) -- --$(PROG3)$(E): gpl/$(PROG3).c -- $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o gpl/$@ gpl/$(PROG3).c $(LIBS) -- -- --# maintenance --------------------------------------------------------------- -- --clean: -- $(RM) -f $(EXES) $(OBJS) -- --# man pages generation ------------------------------------------------------ --man: -- $(MAKE) -C debian -f pod2man.mk PACKAGE=$(PROG) makeman -- $(MAKE) -C debian -f pod2man.mk PACKAGE=$(PROG2) makeman -- $(MAKE) -C debian -f pod2man.mk PACKAGE=$(PROG3) makeman -- --.PHONY: man diff -Nru pngcheck-2.3.0/debian/patches/60-fix-buffer-overflow.patch pngcheck-3.0.3/debian/patches/60-fix-buffer-overflow.patch --- pngcheck-2.3.0/debian/patches/60-fix-buffer-overflow.patch 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/patches/60-fix-buffer-overflow.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -Description: Fix buffer overflow reported in RHBZ #1897485. - When char is signed, casting to a (signed) int directly could produce a - negative offset into the ASCII lookup table; adding an intermediate cast to - uch (a typedef for unsigned char) ensures a nonnegative offset no greater than - 255, which always corresponds to a valid table index. -Origin: vendor, https://src.fedoraproject.org/rpms/pngcheck/blob/cc48791e34201caf7b686084b735d06cef66c974/f/pngcheck-2.4.0-overflow-bz1897485.patch -Bug-Debian: https://bugs.debian.org/976350 -Forwarded: no -Reviewed-By: David da Silva Polverari -Last-Update: 2020-12-04 - ---- a/pngcheck.c -+++ b/pngcheck.c -@@ -4895,8 +4895,10 @@ - /* GRR 20061203: now EBCDIC-safe */ - int check_chunk_name(char *chunk_name, char *fname) - { -- if (isASCIIalpha((int)chunk_name[0]) && isASCIIalpha((int)chunk_name[1]) && -- isASCIIalpha((int)chunk_name[2]) && isASCIIalpha((int)chunk_name[3])) -+ if (isASCIIalpha((int)(uch)chunk_name[0]) && -+ isASCIIalpha((int)(uch)chunk_name[1]) && -+ isASCIIalpha((int)(uch)chunk_name[2]) && -+ isASCIIalpha((int)(uch)chunk_name[3])) - return 0; - - printf("%s%s invalid chunk name \"%.*s\" (%02x %02x %02x %02x)\n", diff -Nru pngcheck-2.3.0/debian/patches/series pngcheck-3.0.3/debian/patches/series --- pngcheck-2.3.0/debian/patches/series 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/patches/series 2022-10-07 23:44:44.000000000 +0000 @@ -1,6 +1,2 @@ -10-pngsplit-format-strings.patch -20-pngsplit-long-options.patch -30-fix-new-source-warnings.patch -40-fix-makefile-unx-dh.patch -50-rename-makefile-unx.patch -60-fix-buffer-overflow.patch +010-makefile.patch +020-manpage_whatis.patch diff -Nru pngcheck-2.3.0/debian/png-fix-IDAT-windowsize.1.pod pngcheck-3.0.3/debian/png-fix-IDAT-windowsize.1.pod --- pngcheck-2.3.0/debian/png-fix-IDAT-windowsize.1.pod 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/png-fix-IDAT-windowsize.1.pod 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -# Copyright -# -# Copyright (C) 2020 David da Silva Polverari -# -# License -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Description -# -# To learn what TOP LEVEL section to use in manual pages, -# see POSIX/Susv standard and "Utility Description Defaults" at -# http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap01.html#tag_01_11 -# -# This is manual page in Perl POD format. Read more at -# http://perldoc.perl.org/perlpod.html or run command: -# -# perldoc perlpod | less -# -# To check the syntax: -# -# podchecker *.pod -# -# Create manual page with command: -# -# pod2man PAGE.N.pod > PAGE.N - -=pod - -=head1 NAME - -png-fix-IDAT-windowsize - fix incorrect window-size fields of IDAT chunks on PNG files - -=head1 SYNOPSIS - -B [B<-force>] [B<-verbose> | B<-noquiet>] I ... - -=head1 OPTIONS - -=over 4 - -=item B<-force> - -Overwrite existing output files. - -=item B<-noquiet> - -See B<-verbose>. - -=item B<-verbose> - -Print more status messages. - -=back - -=head1 DESCRIPTION - -B corrects files with invalid zlib headers -within the PNG (Portable Network Graphics) datastream, as generated by -libpng versions 1.0.16 and 1.2.6. It uses explicit, hardcoded -compression settings and line filters. - -For each input IB<.png>, B performs the -fixes and saves the resulting file as IB<-fixed.png> on the -original file directory. - -=head1 ENVIRONMENT - -None. - -=head1 FILES - -None. - -=head1 SEE ALSO - -pngcheck(1), -pngchunkdesc(1), -pngchunks(1), -pngcomp(1), -pngcp(1), -pngcrush(1), -pngfix(1), -pnginfo(1), -pngmeta(1), -pngnq(1), -pngquant(1), -pngsplit(1) - -=head1 AUTHORS - -Program was written by Greg Roelofs , . - -This manual page was written by David da Silva Polverari - for the Debian GNU system (but may be used -by others). Released under license GNU GPL v2 or (at your option) any -later version. For more information about license, visit -. - -=cut diff -Nru pngcheck-2.3.0/debian/pngcheck.1.pod pngcheck-3.0.3/debian/pngcheck.1.pod --- pngcheck-2.3.0/debian/pngcheck.1.pod 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/pngcheck.1.pod 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ -# Copyright -# -# Copyright (C) 2009-2013 Jari Aalto -# Copyright (C) 2020 David da Silva Polverari -# -# License -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Description -# -# To learn what TOP LEVEL section to use in manual pages, -# see POSIX/Susv standard and "Utility Description Defaults" at -# http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap01.html#tag_01_11 -# -# This is manual page in Perl POD format. Read more at -# http://perldoc.perl.org/perlpod.html or run command: -# -# perldoc perlpod | less -# -# To check the syntax: -# -# podchecker *.pod -# -# Create manual page with command: -# -# pod2man PAGE.N.pod > PAGE.N - -=pod - -=head1 NAME - -pngcheck - Test PNG image files for corruption, display size, type, compression info - -=head1 SYNOPSIS - -B [B<-7cfpqtv>] I.{png|jng|mng} ... - -B [B<-7cfpqstvx>] I ... - -Can be used in a pipeline: - -... | B [B<-7cfpqstvx>] - -=head1 OPTIONS - -=over 4 - -=item B<-7> - -Print contents of tEXt chunks, escape chars >=128 (for 7-bit -terminals). - -=item B<-c> - -Colorize output (for ANSI terminals). - -=item B<-f> - -Force continuation even after major errors. - -=item B<-p> - -Display contents of PLTE, tRNS, hIST, sPLT and PPLT (can be used with -B<-q>). - -=item B<-q> - -Test quietly (only output errors). - -=item B<-s> - -Search for PNGs within another file. - -=item B<-t> - -Print contents of tEXt chunks (can be used with B<-q>). - -=item B<-v> - -Test verbosely (print most chunk data). - -=item B<-vv> - -Test very verbosely (decode and print line filters). - -=item B<-w> - -Suppress windowBits test (more-stringent compression check). - -=item B<-x> - -Search for PNGs within another file and extract them when found. - -=back - -=head1 DESCRIPTION - -pngcheck is the official PNG tester and debugger. Originally designed -simply to test the CRCs within a PNG image file (e.g., to check for -ASCII rather than binary transfer), it has been extended to check and -optionally print almost all the information about a PNG image and to -verify that it conforms to the PNG specification. It also includes -partial support for MNG animations. - -It can dump the chunk-level information in the image in human-readable -form. For example, it can be used to print the basic stats about an -image (dimensions, bit depth, etc.); to list the color and -transparency info in its palette; or to extract the embedded text -annotations. All PNG and JNG chunks are supported, plus almost all MNG -chunks (everything but PAST, DISC, tERm, DROP, DBYK, and ORDR). This -is a command-line program with batch capabilities (e.g., pngcheck -*.png). - -=head1 ENVIRONMENT - -None. - -=head1 FILES - -None. - -=head1 NOTES - -Some PNG files generated through libpng versions 1.0.6 and 1.2.6 may -have an invalid window-size field on the zlib header, causing -B to fail, unless used with the B<-w> (Suppress windowBits -test) option. - -In those cases, the B utility provided by the -B package can be used to correct the window-size field and -compute a new CRC to match the corrected IDAT chunk. Other types of -errors detected by B may require more specialized tools to -fix, such as B. - -=head1 SEE ALSO - -pngchunkdesc(1), -pngchunks(1), -pngcomp(1), -pngcp(1), -pngcrush(1), -pngfix(1), -pnginfo(1), -pngmeta(1), -pngnq(1), -pngquant(1), -pngsplit(1) - -=head1 AUTHORS - -Program was written by Greg Roelofs , . - -This manual page was written by Kevin M. Rosenberg -for the Debian GNU system (but may be used by others). Updated and -converted to Perl POD source format by Jari Aalto -. Released under license GNU GPL v2 or (at your -option) any later version. For more information about license, visit -. - -=cut diff -Nru pngcheck-2.3.0/debian/pngsplit.1.pod pngcheck-3.0.3/debian/pngsplit.1.pod --- pngcheck-2.3.0/debian/pngsplit.1.pod 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/pngsplit.1.pod 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -# Copyright -# -# Copyright (C) 2013 Jari Aalto -# -# License -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Description -# -# To learn what TOP LEVEL section to use in manual pages, -# see POSIX/Susv standard and "Utility Description Defaults" at -# http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap01.html#tag_01_11 -# -# This is manual page in Perl POD format. Read more at -# http://perldoc.perl.org/perlpod.html or run command: -# -# perldoc perlpod | less -# -# To check the syntax: -# -# podchecker *.pod -# -# Create manual page with command: -# -# pod2man PAGE.N.pod > PAGE.N - -=pod - -=head1 NAME - -pngsplit - split a PNG file into individual chunk-files (and check CRCs) - -=head1 SYNOPSIS - -B [B<--force>] [B<--quiet> | B<--verbose>] I ... - -=head1 OPTIONS - -=over 4 - -=item B<--force> - -Overwrite existing output files. - -=item B<--quiet> - -Be quiet. - -=item B<--verbose> - -Display more status messages. - -=back - -=head1 DESCRIPTION - -Split a PNG, MNG or JNG file into individual, numbered chunks like -foo.png.0000.sig, foo.png.0001.IHDR, etc. - -=head1 ENVIRONMENT - -None. - -=head1 FILES - -None. - -=head1 SEE ALSO - -pngcheck(1), -pngchunkdesc(1), -pngchunks(1), -pngcomp(1), -pngcp(1), -pngcrush(1), -pnginfo(1), -pngmeta(1), -pngnq(1), -pngquant(1) - -=head1 AUTHORS - -Program was written by Greg Roelofs , . - -This manual page was written by Jari Aalto . -Released under license GNU GPL v2 or (at your option) any later -version. For more information about license, visit -. - -=cut diff -Nru pngcheck-2.3.0/debian/pod2man.mk pngcheck-3.0.3/debian/pod2man.mk --- pngcheck-2.3.0/debian/pod2man.mk 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/pod2man.mk 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -# pod2man.mk -- Makefile portion to convert *.pod files to manual pages -# -# Copyright information -# -# Copyright (C) 2008-2013 Jari Aalto -# -# License -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Description -# -# Convert *.pod files to manual pages. Write this to 'install' -# target: -# -# install: build $(MANPAGE) - -ifneq (,) - This makefile requires GNU Make. -endif - -# This variable *must* be set when calling -PACKAGE ?= package -RELEASE ?= $(PACKAGE) - -# Optional variables to set -MANSECT ?= 1 -ifdef SOURCE_DATE_EPOCH - PODCENTER ?= $$(date -u -d @${SOURCE_DATE_EPOCH} "+%Y-%m-%d") -else - PODCENTER ?= $$(date "+%Y-%m-%d") -endif - -# Directories -MANSRC = -MANDEST = $(MANSRC) - -MANPOD = $(MANSRC)$(PACKAGE).$(MANSECT).pod -MANPAGE = $(MANDEST)$(PACKAGE).$(MANSECT) - -POD2MAN = pod2man -POD2MAN_FLAGS = --utf8 - -makeman: $(MANPAGE) - -$(MANPAGE): $(MANPOD) - # make target - create manual page from a *.pod page - podchecker $(MANPOD) - LC_ALL=C $(POD2MAN) $(POD2MAN_FLAGS) \ - --center="$(PODCENTER)" \ - --name="$(PACKAGE)" \ - --section="$(MANSECT)" \ - --release="$(RELEASE)" \ - $(MANPOD) \ - > $(MANPAGE) && \ - rm -f pod*.tmp - -# End of of Makefile part diff -Nru pngcheck-2.3.0/debian/rules pngcheck-3.0.3/debian/rules --- pngcheck-2.3.0/debian/rules 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/rules 2022-10-07 23:44:44.000000000 +0000 @@ -3,10 +3,13 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic -export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed # Fixes FTCBFS. See https://bugs.debian.org/895298 -include /usr/share/dpkg/buildtools.mk %: dh $@ + +# Avoids FTCBFS by passing CC to make explicitly. +override_dh_auto_build: + make CC=$(CC) -f Makefile.unx diff -Nru pngcheck-2.3.0/debian/tests/control pngcheck-3.0.3/debian/tests/control --- pngcheck-2.3.0/debian/tests/control 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/tests/control 2022-11-24 14:35:09.000000000 +0000 @@ -1,7 +1,8 @@ Test-Command: pngcheck -h Restrictions: superficial -Test-Command: pngcheck debian/tests/openlogo-nd-100.png +Test-Command: pngcheck debian/tests/openlogo-nd-100.png | grep '^OK:' +Restrictions: allow-stderr Test-Command: pngsplit 2>&1 | grep pngsplit Restrictions: allow-stderr, superficial diff -Nru pngcheck-2.3.0/debian/watch pngcheck-3.0.3/debian/watch --- pngcheck-2.3.0/debian/watch 2020-12-04 07:24:15.000000000 +0000 +++ pngcheck-3.0.3/debian/watch 2022-12-05 13:50:42.000000000 +0000 @@ -1,2 +1,3 @@ version=4 -https://sf.net/png-mng/ pngcheck-(\d\S+)\.tar\.(?:bz2|gz|xz) +opts="pagemangle=s{ row-filter byte ucsize = bytewidth * height; - numfilters = height; + //numfilters = height; if (bitwidth/width != bitsperpixel || bytewidth <= 0 || ucsize/bytewidth != height) @@ -434,7 +433,7 @@ //inptr currently points at "length" bytes of first chunk after IHDR - csize_orig = 0L; + //csize_orig = 0L; error = haveEOF = haveIDAT = FALSE; while (!error && !haveEOF) { @@ -455,7 +454,7 @@ if (chunktyp == IDAT) { haveIDAT = TRUE; file_offset_IDATs = file_offset - 8; // start of chunklen - csize_orig += chunklen; + //csize_orig += chunklen; break; } @@ -530,9 +529,9 @@ file_offset = file_offset_IDATs; cptr = cbuf; - csize = csize_orig; + //csize = csize_orig; - fread(cbuf, 1, chunklen+12, infile); + incnt = fread(cbuf, 1, chunklen+12, infile); calc_crc = crc32(0L, Z_NULL, 0); calc_crc = crc32(calc_crc, cbuf+4, chunklen+4); diff -Nru pngcheck-2.3.0/gpl/pngsplit.1 pngcheck-3.0.3/gpl/pngsplit.1 --- pngcheck-2.3.0/gpl/pngsplit.1 1970-01-01 00:00:00.000000000 +0000 +++ pngcheck-3.0.3/gpl/pngsplit.1 2020-10-31 19:03:58.000000000 +0000 @@ -0,0 +1,28 @@ +.TH PNGSPLIT "1" "October 2020" "pngsplit 1.0" "User Commands" +.SH NAME +pngsplit \- manual page for pngsplit 1.0 +.SH SYNOPSIS +.B pngsplit +.RI [ options ] +.I pngfile +.RI [ pngfile \ [...]] +.SH DESCRIPTION +pngsplit, version 1.0 of 31 October 2020, by Greg Roelofs. +.PP +Split a PNG, MNG or JNG file into individual, numbered chunks (filenames +"foo.png.0000.sig", "foo.png.0001.IHDR", etc.). +.PP +This software is licensed under the GNU General Public License. +There is NO warranty. +.SH OPTIONS +.TP +.B \-force +overwrite existing output files +.TP +.B \-verbose +print more status messages (synonym: +.BR \-noquiet ) +.IP +.SH "SEE ALSO" +.BR pngcheck (1), +.BR png-fix-IDAT-windowsize (1) diff -Nru pngcheck-2.3.0/gpl/pngsplit.c pngcheck-3.0.3/gpl/pngsplit.c --- pngcheck-2.3.0/gpl/pngsplit.c 2007-02-11 21:46:23.000000000 +0000 +++ pngcheck-3.0.3/gpl/pngsplit.c 2020-10-31 19:03:39.000000000 +0000 @@ -9,7 +9,7 @@ ** gcc -Wall -O2 -I../zlib pngsplit.c -o pngsplit -L../zlib -lz ** ** -** Copyright 2005-2006 Greg Roelofs +** Copyright 2005-2020 Greg Roelofs ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ ** */ -#define VERSION "0.60 BETA of 11 February 2007" +#define VERSION "1.0 of 31 October 2020" /* * TO DO: @@ -78,18 +78,18 @@ ((ulg)(((uch *)(x))[2]) << 8) | \ ((ulg)(((uch *)(x))[3]) ) ) -static const char *pngsplit_hdr = "\ +#define PNGSPLIT_HDR "\ pngsplit, version " VERSION ", by Greg Roelofs.\n\ This software is licensed under the GNU General Public License.\n\ - There is NO warranty.\n\n"; + There is NO warranty.\n\n" -static const char *pngsplit_usage = "\ +#define PNGSPLIT_USAGE "\ usage: pngsplit [options] pngfile [pngfile [...]]\n\ options:\n\ -force overwrite existing output files\n\ -verbose print more status messages (synonym: -noquiet)\n\n\ Split a PNG, MNG or JNG file into individual, numbered chunks (filenames\n\ - \"foo.png.0000.sig\", \"foo.png.0001.IHDR\", etc.).\n"; + \"foo.png.0000.sig\", \"foo.png.0001.IHDR\", etc.).\n" static const uch pngsig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; static const uch mngsig[8] = {138, 77, 78, 71, 13, 10, 26, 10}; @@ -141,8 +141,8 @@ 0 == strncmp( argv[argn], "-quiet", 2 ) ) verbose = 0; else { - fprintf(stderr, pngsplit_hdr); - fprintf(stderr, pngsplit_usage); + fprintf(stderr, PNGSPLIT_HDR); + fprintf(stderr, PNGSPLIT_USAGE); fflush(stderr); return 1; } @@ -150,8 +150,8 @@ } if ( argn == argc ) { - fprintf(stderr, pngsplit_hdr); - fprintf(stderr, pngsplit_usage); + fprintf(stderr, PNGSPLIT_HDR); + fprintf(stderr, PNGSPLIT_USAGE); fflush(stderr); return 5; } else { @@ -162,7 +162,7 @@ /*============================= MAIN LOOP =============================*/ - fprintf(stdout, pngsplit_hdr); + fprintf(stdout, PNGSPLIT_HDR); fflush(stdout); while (argn <= argc) { diff -Nru pngcheck-2.3.0/pngcheck.1 pngcheck-3.0.3/pngcheck.1 --- pngcheck-2.3.0/pngcheck.1 1970-01-01 00:00:00.000000000 +0000 +++ pngcheck-3.0.3/pngcheck.1 2021-04-26 04:11:41.000000000 +0000 @@ -0,0 +1,57 @@ +.TH PNGCHECK "1" "April 2021" "pngcheck 3.0.3" "User Commands" +.SH NAME +pngcheck \- manual page for pngcheck 3.0.3 +.SH SYNOPSIS +.B pngcheck +.RI [ \-7cpqtv ] +.I file.{png|jng|mng} +.RI [ file2.{png|jng|mng} \ [...]] +.br +.RB ...\ |\ pngcheck +.RI [ \-7cpqstvx ] +.br +.B pngcheck +.RI [ \-7cpqstvx ] \ file-containing-PNGs ... +.SH DESCRIPTION +PNGcheck, version 3.0.3 of 25 April 2021, +by Alexander Lehmann, Andreas Dilger and Greg Roelofs. +.PP +Test PNG, JNG or MNG image files for corruption, and print size/type info. +.SH OPTIONS +.TP +.B \-7 +print contents of tEXt chunks, escape chars >=128 (for 7\-bit terminals) +.TP +.B \-c +colorize output (for ANSI terminals) +.TP +.B \-p +print contents of PLTE, tRNS, hIST, sPLT and PPLT (can be used with +.BR \-q ) +.TP +.B \-q +test quietly (output only errors) +.TP +.B \-s +search for PNGs within another file +.TP +.B \-t +print contents of tEXt chunks (can be used with +.BR \-q ) +.TP +.B \-v +test verbosely (print most chunk data) +.TP +.B \-vv +test very verbosely (decode & print line filters) +.TP +.B \-w +suppress windowBits test (more\-stringent compression check) +.TP +.B \-x +search for PNGs within another file and extract them when found +.SH NOTE +MNG support is more informational than conformance\-oriented. +.SH "SEE ALSO" +.BR pngsplit (1), +.BR png-fix-IDAT-windowsize (1) diff -Nru pngcheck-2.3.0/pngcheck.c pngcheck-3.0.3/pngcheck.c --- pngcheck-2.3.0/pngcheck.c 2007-07-08 06:23:31.000000000 +0000 +++ pngcheck-3.0.3/pngcheck.c 2021-04-26 04:21:03.000000000 +0000 @@ -17,7 +17,7 @@ /*============================================================================ * - * Copyright 1995-2007 by Alexander Lehmann , + * Copyright 1995-2021 by Alexander Lehmann , * Andreas Dilger , * Glenn Randers-Pehrson , * Greg Roelofs , @@ -33,7 +33,7 @@ * *===========================================================================*/ -#define VERSION "2.3.0 of 7 July 2007" +#define VERSION "3.0.3 of 25 April 2021" /* * NOTE: current MNG support is informational; error-checking is MINIMAL! @@ -45,9 +45,9 @@ * * PLTE IDAT IEND // critical PNG chunks * - * bKGD cHRM fRAc gAMA gIFg gIFt gIFx hIST // ancillary PNG chunks - * iCCP iTXt oFFs pCAL pHYs sBIT sCAL sPLT - * sRGB tEXt zTXt tIME tRNS + * bKGD cHRM eXIf fRAc gAMA gIFg gIFt gIFx // ancillary PNG chunks + * hIST iCCP iTXt oFFs pCAL pHYs sBIT sCAL + * sPLT sRGB sTER tEXt zTXt tIME tRNS * * cmOD cmPP cpIp mkBF mkBS mkBT mkTS pcLb // known private PNG chunks * prVW spAL // [msOG = ??] @@ -69,16 +69,17 @@ * - fix tEXt chunk: small buffers or lots of text => truncation * (see pngcheck-1.99.4-test.c.dif) * - fix iCCP, sPLT chunks: small buffers or large chunks => truncation? - * - update existing MNG support to version 1.0 (already done?) + * - update existing MNG support to version 1.0 (DHDR bug just fixed 2010!) * - add JNG restrictions to bKGD * - allow top-level ancillary PNGs in MNG (i.e., subsequent ones may be NULL) * * add MNG profile report based on actual chunks found - * - split out each chunk's code into XXXX() function (e.g., IDAT(), tRNS()) + * - REFACTOR THE WHOLE THING! split out each chunk's code into a separate + * XXXX() function (e.g., IDAT(), tRNS()) * * with USE_ZLIB, print zTXt and compressed iTXt chunks if -t option * (break out zlib decoder into separate function and reuse) * (also iCCP?) - * - DOS/Win32 wildcard support beyond emx+gcc, MSVC (Borland wildargs.obj?) - * - EBCDIC support (minimal?) + * ? DOS/Win32 wildcard support beyond emx+gcc, MSVC (Borland wildargs.obj?) + * ? EBCDIC support (minimal?) * - go back and make sure validation checks not dependent on verbosity level * * @@ -92,11 +93,13 @@ * Compilation example (GNU C, command line; replace "/zlibpath" appropriately): * * without zlib: - * gcc -O -o pngcheck pngcheck.c + * gcc -Wall -O -o pngcheck pngcheck.c * with zlib support (recommended): - * gcc -O -DUSE_ZLIB -I/zlibpath -o pngcheck pngcheck.c -L/zlibpath -lz + * gcc -Wall -O -DUSE_ZLIB -o pngcheck pngcheck.c -lz + * or (if zlib lives in non-standard location): + * gcc -Wall -O -DUSE_ZLIB -I/zlibpath -o pngcheck pngcheck.c -L/zlibpath -lz * or (static zlib): - * gcc -O -DUSE_ZLIB -I/zlibpath -o pngcheck pngcheck.c /zlibpath/libz.a + * gcc -Wall -O -DUSE_ZLIB -I/zlibpath -o pngcheck pngcheck.c /zlibpath/libz.a * * Windows compilation example (MSVC, command line, assuming VCVARS32.BAT or * whatever has been run): @@ -198,6 +201,8 @@ char *keyword_name, char *chunkid, char *fname); int check_text (uch *buffer, int maxsize, char *chunkid, char *fname); int check_ascii_float (uch *buffer, int len, char *chunkid, char *fname); +char const * u2name_helper(unsigned int value, const char **names, + size_t nnames); #define BS 32000 /* size of read block for CRC calculation (and zlib) */ @@ -212,22 +217,25 @@ /* GRR 20070704: borrowed from GRR from/mailx hack */ #define COLOR_NORMAL "\033[0m" -#define COLOR_RED_BOLD "\033[01;31m" +#define COLOR_RED_BOLD "\033[40;31;1m" #define COLOR_RED "\033[40;31m" -#define COLOR_GREEN_BOLD "\033[01;32m" +#define COLOR_GREEN_BOLD "\033[40;32;1m" #define COLOR_GREEN "\033[40;32m" -#define COLOR_YELLOW_BOLD "\033[01;33m" +#define COLOR_YELLOW_BOLD "\033[40;33;1m" #define COLOR_YELLOW "\033[40;33m" /* chunk names */ -#define COLOR_BLUE_BOLD "\033[01;34m" +#define COLOR_BLUE_BOLD "\033[40;34;1m" #define COLOR_BLUE "\033[40;34m" -#define COLOR_MAGENTA_BOLD "\033[01;35m" +#define COLOR_MAGENTA_BOLD "\033[40;35;1m" #define COLOR_MAGENTA "\033[40;35m" -#define COLOR_CYAN_BOLD "\033[01;36m" +#define COLOR_CYAN_BOLD "\033[40;36;1m" #define COLOR_CYAN "\033[40;36m" -#define COLOR_WHITE_BOLD "\033[01;37m" /* filenames, filter seps */ +#define COLOR_WHITE_BOLD "\033[40;37;1m" /* filenames, filter seps */ #define COLOR_WHITE "\033[40;37m" #define isASCIIalpha(x) (ascii_alpha_table[x] & 0x1) +/* Map unsigned value to enumerated string name, safely with fallback */ +#define U2NAME(x, names) (u2name_helper(x, &names[0], \ + sizeof(names) / sizeof(names[0]))) #define ANCILLARY(chunkID) ((chunkID)[0] & 0x20) #define PRIVATE(chunkID) ((chunkID)[1] & 0x20) @@ -237,8 +245,8 @@ #define PUBLIC(chunkID) (!PRIVATE(chunkID)) #define set_err(x) global_error = ((global_error < (x))? (x) : global_error) -#define is_err(x) (global_error > (x) || (!force && global_error == (x))) -#define no_err(x) (global_error < (x) || (force && global_error == (x))) +#define is_err(x) (global_error >= (x)) +#define no_err(x) (global_error < (x)) enum { kOK = 0, @@ -256,7 +264,6 @@ int printpal = 0; /* print PLTE/tRNS/hIST/sPLT contents */ int color = 0; /* print with ANSI colors to spice things up */ int sevenbit = 0; /* escape characters >=160 */ -int force = 0; /* continue even if an error occurs (CRC error, etc) */ int check_windowbits = 1; /* more stringent zlib stream-checking */ int suppress_warnings = 0; /* don't fuss about ambiguous stuff */ int search = 0; /* hunt for PNGs in the file... */ @@ -313,7 +320,7 @@ #ifdef USE_ZLIB int first_idat = 1; /* flag: is this the first IDAT chunk? */ - int zlib_error = 0; /* reset in IHDR section; used for IDAT */ + int zlib_error = 0; /* gets reset in IHDR section; used for IDAT */ int check_zlib = 1; /* validate zlib stream (just IDATs for now) */ unsigned zlib_windowbits = 15; uch outbuf[BS]; @@ -581,10 +588,6 @@ color = 1; ++i; break; - case 'f': - force = 1; - ++i; - break; case 'h': usage(stdout); return err; @@ -667,13 +670,13 @@ #ifdef USE_ZLIB /* make sure we're using the zlib version we were compiled to use */ if (zlib_version[0] != ZLIB_VERSION[0]) { - printf("zlib error: incompatible version (expected %s," + fprintf(stderr, "zlib error: incompatible version (expected %s," " using %s): skipping zlib check\n\n", ZLIB_VERSION, zlib_version); check_zlib = 0; if (verbose > 1) verbose = 1; } else if (strcmp(zlib_version, ZLIB_VERSION) != 0) { - printf("zlib warning: different version (expected %s," + fprintf(stderr, "zlib warning: different version (expected %s," " using %s)\n\n", ZLIB_VERSION, zlib_version); } #endif /* USE_ZLIB */ @@ -749,14 +752,13 @@ fprintf(fpMsg, "\n" "Test PNG, JNG or MNG image files for corruption, and print size/type info." "\n\n" - "Usage: pngcheck [-7cfpqtv] file.{png|jng|mng} [file2.{png|jng|mng} [...]]\n" - " or: ... | pngcheck [-7cfpqstvx]\n" - " or: pngcheck [-7cfpqstvx] file-containing-PNGs...\n" + "Usage: pngcheck [-7cpqtv] file.{png|jng|mng} [file2.{png|jng|mng} [...]]\n" + " or: ... | pngcheck [-7cpqstvx]\n" + " or: pngcheck [-7cpqstvx] file-containing-PNGs...\n" "\n" "Options:\n" " -7 print contents of tEXt chunks, escape chars >=128 (for 7-bit terminals)\n" " -c colorize output (for ANSI terminals)\n" - " -f force continuation even after major errors\n" " -p print contents of PLTE, tRNS, hIST, sPLT and PPLT (can be used with -q)\n" " -q test quietly (output only errors)\n" " -s search for PNGs within another file\n" @@ -764,7 +766,7 @@ " -v test verbosely (print most chunk data)\n" #ifdef USE_ZLIB " -vv test very verbosely (decode & print line filters)\n" - " -w suppress windowBits test (more-stringent compression check)\n" + " -w suppress windowBits test (a more-stringent compression check)\n" #endif " -x search for PNGs within another file and extract them when found\n" "\n" @@ -884,6 +886,8 @@ /* GRR EBCDIC WARNING */ void print_buffer(printbuf_state *prbuf, uch *buf, int size, int indent) { + if (size < 1) + return; if (indent) printf(" "); while (size--) { @@ -1023,12 +1027,12 @@ int c; int have_IHDR = 0, have_IEND = 0; int have_MHDR = 0, have_MEND = 0; - int have_DHDR = 0, have_PLTE = 0; + int /* have_DHDR = 0, */ have_PLTE = 0; int have_JHDR = 0, have_JSEP = 0, need_JSEP = 0; int have_IDAT = 0, have_JDAT = 0, last_is_IDAT = 0, last_is_JDAT = 0; - int have_bKGD = 0, have_cHRM = 0, have_gAMA = 0, have_hIST = 0, have_iCCP = 0; - int have_oFFs = 0, have_pCAL = 0, have_pHYs = 0, have_sBIT = 0, have_sCAL = 0; - int have_sRGB = 0, have_sTER = 0, have_tIME = 0, have_tRNS = 0; + int have_bKGD = 0, have_cHRM = 0, have_eXIf = 0, have_gAMA = 0, have_hIST = 0; + int have_iCCP = 0, have_oFFs = 0, have_pCAL = 0, have_pHYs = 0, have_sBIT = 0; + int have_sCAL = 0, have_sRGB = 0, have_sTER = 0, have_tIME = 0, have_tRNS = 0; int have_SAVE = 0, have_TERM = 0, have_MAGN = 0, have_pHYg = 0; int top_level = 1; ulg zhead = 1; /* 0x10000 indicates both zlib header bytes read */ @@ -1136,20 +1140,18 @@ mng? 'M':'I'); set_err(kMinorError); - if (!force) - return global_error; + return global_error; } sz = getlong(fp, fname, "chunk length"); - if (is_err(kMajorError)) /* FIXME: return only if !force? */ + if (is_err(kMajorError)) return global_error; if (sz < 0 || sz > 0x7fffffff) { /* FIXME: convert to ulg, lose "< 0" */ printf("%s invalid chunk length (too large)\n", verbose? ":":fname); set_err(kMajorError); - /* if (!force) */ /* code not yet vetted for negative sz */ - return global_error; + return global_error; } if (fread(chunkid, 1, 4, fp) != 4) { @@ -1165,8 +1167,7 @@ if (check_chunk_name(chunkid, fname) != 0) { set_err(kMajorError); - if (!force) - return global_error; + return global_error; } if (verbose) @@ -1186,8 +1187,7 @@ printf("%s first chunk must be %cHDR\n", verbose? ":":fname, png? 'I' : (mng? 'M':'J')); set_err(kMinorError); - if (!force) - return global_error; + return global_error; } toread = (sz > BS)? BS:sz; @@ -1242,7 +1242,7 @@ if (ityp == 2 || ityp == 4 || ityp == 6) { /* RGB or GA or RGBA */ printf("%s invalid %ssample depth (%d) for %s image\n", verbose? ":":fname, verbose? "":"IHDR ", sampledepth, - png_type[ityp]); + U2NAME(ityp, png_type)); set_err(kMinorError); } break; @@ -1252,7 +1252,7 @@ if (ityp == 3) { /* palette */ printf("%s invalid %ssample depth (%d) for %s image\n", verbose? ":":fname, verbose? "":"IHDR ", sampledepth, - png_type[ityp]); + U2NAME(ityp, png_type)); set_err(kMinorError); } break; @@ -1306,7 +1306,7 @@ } if (verbose && no_err(kMinorError)) { printf("\n %ld x %ld image, %d-bit %s, %sinterlaced\n", w, h, - bitdepth, png_type[ityp], lace? "":"non-"); + bitdepth, U2NAME(ityp, png_type), lace? "":"non-"); } } have_IHDR = 1; @@ -1391,15 +1391,16 @@ { printf("%s invalid %salpha-channel bit depth (%d) for %s image\n" , verbose? ":":fname, verbose? "":"JHDR ", alphadepth, - jng_type[jtyp]); + U2NAME(jtyp, jng_type)); set_err(kMinorError); } else if (verbose && no_err(kMinorError)) { if (jtyp < 2) printf("\n %ld x %ld image, %d-bit %s%s%s\n", - w, h, jbitd, and, jng_type[jtyp], lace? ", progressive":""); + w, h, jbitd, and, U2NAME(jtyp, jng_type), + lace? ", progressive":""); else printf("\n %ld x %ld image, %d-bit %s%s + %d-bit alpha%s\n", - w, h, jbitd, and, jng_type[jtyp-2], alphadepth, + w, h, jbitd, and, U2NAME(jtyp-2, jng_type), alphadepth, lace? ", progressive":""); } } @@ -1429,7 +1430,7 @@ } if (no_err(kMinorError)) { ulg tps, playtime, profile; - int validtrans = 0; + /* int validtrans = 0; */ mng_width = w = LG(buffer); mng_height = h = LG(buffer+4); @@ -1505,7 +1506,7 @@ printf("%s%svalid transparency info", bits? ", " : "", (bits > 0 && (bits % 3) == 0)? "\n " : ""); ++bits; - validtrans = 1; + /* validtrans = 1; */ } if (/* validtrans && */ profile & 0x0080) { if (verbose) @@ -1585,7 +1586,7 @@ set_err(kMinorError); } else if (png && ityp != 3 && ityp != 2 && ityp != 6) { printf("%s PLTE not allowed in %s image\n", verbose? ":":fname, - png_type[ityp]); + U2NAME(ityp, png_type)); set_err(kMinorError); } else if (png && have_IDAT) { printf("%s %smust precede IDAT\n", @@ -1660,12 +1661,12 @@ } } else if (png && ityp == 3 && !have_PLTE) { printf("%s %smust follow PLTE in %s image\n", - verbose? ":":fname, verbose? "":"IDAT ", png_type[ityp]); + verbose? ":":fname, verbose? "":"IDAT ", U2NAME(ityp, png_type)); set_err(kMajorError); } else if (verbose) printf("\n"); - if (!no_err(kMinorError) && !force) + if (!no_err(kMinorError)) return global_error; /* We just want to check that we have read at least the minimum (10) @@ -1708,11 +1709,11 @@ } else if (CM == 8) { if (CINFO > 1) { printf("deflated, %dK window, %s compression%s\n", - (1 << (CINFO-2)), deflate_type[FLEVEL], + (1 << (CINFO-2)), U2NAME(FLEVEL, deflate_type), FDICT? ", preset dictionary":""); } else { printf("deflated, %d-byte window, %s compression%s\n", - (1 << (CINFO+8)), deflate_type[FLEVEL], + (1 << (CINFO+8)), U2NAME(FLEVEL, deflate_type), FDICT? ", preset dictionary":""); } } else { @@ -1736,7 +1737,6 @@ zstrm.next_in = buffer; zstrm.avail_in = toread; -// FIXME! when inflate error and force, need to skip over rest of IDAT /* initialize zlib and bit/byte/line variables if not already done */ if (first_idat) { zstrm.next_out = p = outbuf; @@ -1810,15 +1810,23 @@ err = inflate(&zstrm, Z_SYNC_FLUSH); if (err != Z_OK && err != Z_STREAM_END) { printf("%s zlib: inflate error = %d (%s)\n", - verbose > 1? "\n " : (verbose == 1? " ":fname), err, + verbose > 1? "\n " : (verbose == 1? " " : fname), err, (-err < 1 || -err > 6)? "unknown":zlib_error_type[-err-1]); zlib_error = 1; /* fatal error only for this PNG */ - break; /* kill inner loop */ + break; /* kill zlib loop */ } /* now have uncompressed, filtered image data in outbuf */ eod = outbuf + BS - zstrm.avail_out; while (p < eod) { + /* GRR 20210425: protect against run-on data, intentional or otherwise */ + if ((lace && cur_pass > 7) || (!lace && cur_y > h)) { + printf("%s extra data beyond end of image: possible exploit attempt\n", + verbose > 1? "\n " : (verbose == 1? " " : fname)); + zlib_error = 1; /* fatal error only for this PNG */ + err = Z_STREAM_END; /* kill middle loop */ + break; /* kill "innermost" loop (not counting short-image interlace one) */ + } if (cur_linebytes) { /* GRP 20000727: bugfix */ int filttype = p[0]; @@ -1910,12 +1918,23 @@ cur_yoff = 0; } cur_y = cur_yoff; + /* 20210416: fix by Ben Beasley for bug found by chiba of topsec alpha lab */ + if (cur_xskip == 0) { + printf("%s invalid interlacing state (zero xskip) in image data\n", + verbose > 1? "\n " : (verbose == 1? " " : fname)); + zlib_error = 1; /* fatal error only for this PNG */ + break; + } /* effective width is reduced if even pass: subtract cur_xoff */ cur_width = (w - cur_xoff + cur_xskip - 1) / cur_xskip; cur_linebytes = ((cur_width*bitdepth + 7) >> 3) + 1; if (cur_linebytes == 1) /* just the filter byte? no can do */ cur_linebytes = 0; /* GRP 20000727: added fix */ } + if (zlib_error) { /* GRR 20210425: propagate error out of remaining loops */ + err = Z_STREAM_END; /* kill middle loop */ + break; /* kill "innermost" loop (not counting short-image interlace one) */ + } } else if (cur_y >= h) { if (verbose > 3) { /* GRR 20000304: bad code */ printf(" %td bytes remaining in buffer before inflateEnd()", @@ -1931,32 +1950,36 @@ fflush(stdout); } else inflateEnd(&zstrm); /* we're all done */ - zlib_error = -1; /* kill outermost loop (over chunks) */ + zlib_error = -1; /* kill outermost loop (over consecutive PNG-mode IDAT chunks) */ err = Z_STREAM_END; /* kill middle loop */ - break; /* kill innermost loop */ + break; /* kill "innermost" loop (not counting short-image interlace one) */ } - } - p -= (eod - outbuf); /* wrap p back into outbuf region */ - zstrm.next_out = outbuf; - zstrm.avail_out = BS; + } /* end of byte-loop over uncompressed data */ - /* get more input (waiting until buffer empties is not necessary best - * zlib strategy, but simpler than shifting leftover data around) */ - if (zstrm.avail_in == 0 && sz > toread) { - int data_read; - - sz -= toread; - toread = (sz > BS)? BS:sz; - if ((data_read = fread(buffer, 1, toread, fp)) != toread) { - printf("\nEOF while reading %s data\n", chunkid); - set_err(kCriticalError); - return global_error; + if (!zlib_error && no_err(kMinorError)) { + p -= (eod - outbuf); /* wrap p back into outbuf region */ + zstrm.next_out = outbuf; + zstrm.avail_out = BS; + + /* get more input (waiting until buffer empties is not necessary best + * zlib strategy, but simpler than shifting leftover data around) */ + if (zstrm.avail_in == 0 && sz > toread) { + int data_read; + + sz -= toread; + toread = (sz > BS)? BS:sz; + if ((data_read = fread(buffer, 1, toread, fp)) != toread) { + printf("\nEOF while reading %s data\n", chunkid); + set_err(kCriticalError); + return global_error; + } + crc = update_crc(crc, buffer, toread); + zstrm.next_in = buffer; + zstrm.avail_in = toread; } - crc = update_crc(crc, buffer, toread); - zstrm.next_in = buffer; - zstrm.avail_in = toread; } - } + } /* end of zlib decoding loop */ + if (verbose > 1 && no_err(kMinorError)) printf("%s (%ld out of %ld)\n", color_off, numfilt, numfilt_total); } @@ -2120,6 +2143,30 @@ last_is_IDAT = last_is_JDAT = 0; /*------* + | eXIf | + *------*/ + } else if (strcmp(chunkid, "eXIf") == 0) { + if (jng) { + printf("%s eXIf not defined in JNG\n", verbose? ":":fname); + set_err(kMinorError); + } else if (png && have_eXIf) { + printf("%s multiple eXIf not allowed\n", verbose? ":":fname); + set_err(kMinorError); + } + else if (verbose /* && no_err(kMinorError) */) { + if (SH(buffer) == 0x4d4d && buffer[2] == 0 && buffer[3] == 0x2a) { + printf(": EXIF metadata, big-endian (MM) format\n"); + } else if (SH(buffer) == 0x4949 && buffer[2] == 0x2a && buffer[3] == 0) { + printf(": EXIF metadata, little-endian (II) format\n"); + } else { + printf(": EXIF metadata, unrecognized format: 0x%02x 0x%02x 0x%02x 0x%02x\n", + buffer[0], buffer[1], buffer[2], buffer[3]); + } + } + have_eXIf = 1; + last_is_IDAT = last_is_JDAT = 0; + + /*------* | fRAc | *------*/ } else if (strcmp(chunkid, "fRAc") == 0) { @@ -2152,6 +2199,11 @@ verbose? ":":fname, verbose? "":"gAMA "); set_err(kMinorError); } + // FIXME? probably need to distinguish from minor errors in this chunk + // (no need for new line) and those in previous chunks (need newline for + // verbose mode, and no real harm in printing gAMA info, too); likely + // applies to many other chunks as well, but need to create an appropriate + // test PNG to verify if (verbose && no_err(kMinorError)) { printf(": %#0.5g\n", (double)LG(buffer)/100000); } @@ -2253,7 +2305,11 @@ printf(" hIST chunk"); printf(": %ld histogram entr%s\n", sz / 2, sz/2 == 1? "y":"ies"); } - if (printpal && no_err(kMinorError)) { + if (sz > BS) { + printf("%s invalid %slength\n", /* or input buffer too small */ + verbose? ":":fname, verbose? "":"hIST "); + set_err(kMinorError); + } else if (printpal && no_err(kMinorError)) { char *spc; if (sz < 10) @@ -2687,6 +2743,11 @@ printf("%s invalid %slength\n", verbose? ":":fname, verbose? "":"sCAL "); set_err(kMinorError); + } else if (sz > BS) { + /* FIXME: large sCAL chunks are unusual, but should be supported */ + printf("%s checking large %schunk not currently supported\n", + verbose? ":":fname, verbose? "":"sCAL "); + set_err(kMinorError); } else if (unittype < 1 || unittype > 2) { printf("%s invalid %sunit specifier (%d)\n", verbose? ":":fname, verbose? "":"sCAL ", unittype); @@ -2710,6 +2771,10 @@ } } if (no_err(kMinorError)) { + if (pPixheight == NULL) { + /* missing pixel height, but -f was given */ + pPixheight = buffer+sz; + } for (qq = pPixheight; qq < buffer+sz; ++qq) { if (*qq == 0) break; @@ -2719,7 +2784,8 @@ verbose? ":":fname, verbose? "":"sCAL "); set_err(kWarning); } - if (*pPixwidth == '-' || *pPixheight == '-') { + if (*pPixwidth == '-' || + (pPixheight != buffer+sz && *pPixheight == '-')) { printf("%s invalid negative %svalue(s)\n", verbose? ":":fname, verbose? "":"sCAL "); set_err(kMinorError); @@ -2795,7 +2861,7 @@ } if (printpal && no_err(kMinorError)) { char *spc; - int i, j = name_len+2; + int i, j = name_len+2, jstep = ((bytes == 1) ? 6 : 10); if (nsplt < 10) spc = " "; @@ -2807,17 +2873,24 @@ spc = " "; else spc = " "; + + /* TODO: Support larger sPLT contents with an input-reading loop */ + if (nsplt > (BS - j) / jstep) { + printf("%s printing truncated %scontents\n", + verbose? ":":fname, verbose? "":"sPLT "); + nsplt = (BS - j) / jstep; + } /* GRR: could check for (required) non-increasing freq order */ /* GRR: could also check for all zero freqs: undefined hist */ if (bytes == 1) { - for (i = 0; i < nsplt; ++i, j += 6) + for (i = 0; i < nsplt; ++i, j += jstep) printf("%s%3d: (%3u,%3u,%3u,%3u) = " "(0x%02x,0x%02x,0x%02x,0x%02x) freq = %u\n", spc, i, buffer[j], buffer[j+1], buffer[j+2], buffer[j+3], buffer[j], buffer[j+1], buffer[j+2], buffer[j+3], SH(buffer+j+4)); } else { - for (i = 0; i < nsplt; ++i, j += 10) + for (i = 0; i < nsplt; ++i, j += jstep) printf("%s%5d: (%5u,%5u,%5u,%5u) = (%04x,%04x,%04x,%04x) " "freq = %u\n", spc, i, SH(buffer+j), SH(buffer+j+2), SH(buffer+j+4), SH(buffer+j+6), SH(buffer+j), SH(buffer+j+2), @@ -2856,7 +2929,8 @@ set_err(kMinorError); } if (verbose && no_err(kMinorError)) { - printf("\n rendering intent = %s\n", rendering_intent[buffer[0]]); + printf("\n rendering intent = %s\n", + U2NAME(buffer[0], rendering_intent)); } have_sRGB = 1; last_is_IDAT = last_is_JDAT = 0; @@ -3030,7 +3104,8 @@ case 0: if (sz != 2) { printf("%s invalid %slength for %s image\n", - verbose? ":":fname, verbose? "":"tRNS ", png_type[ityp]); + verbose? ":":fname, verbose? "":"tRNS ", + U2NAME(ityp, png_type)); set_err(kMajorError); } else if (verbose && no_err(kMinorError)) { printf("\n gray = 0x%04x\n", SH(buffer)); @@ -3039,7 +3114,8 @@ case 2: if (sz != 6) { printf("%s invalid %slength for %s image\n", - verbose? ":":fname, verbose? "":"tRNS ", png_type[ityp]); + verbose? ":":fname, verbose? "":"tRNS ", + U2NAME(ityp, png_type)); set_err(kMajorError); } else if (verbose && no_err(kMinorError)) { printf("\n red = 0x%04x, green = 0x%04x, blue = 0x%04x\n", @@ -3049,10 +3125,10 @@ case 3: if (sz > nplte) { printf("%s invalid %slength for %s image\n", - verbose? ":":fname, verbose? "":"tRNS ", png_type[ityp]); + verbose? ":":fname, verbose? "":"tRNS ", + U2NAME(ityp, png_type)); set_err(kMajorError); - } else if ((verbose || (printpal && !quiet)) && no_err(kMinorError)) - { + } else if ((verbose || (printpal && !quiet)) && no_err(kMinorError)) { if (!verbose && printpal && !quiet) printf(" tRNS chunk"); printf(": %ld transparency entr%s\n", sz, sz == 1? "y":"ies"); @@ -3072,7 +3148,8 @@ break; default: printf("%s %snot allowed in %s image\n", - verbose? ":":fname, verbose? "":"tRNS ", png_type[ityp]); + verbose? ":":fname, verbose? "":"tRNS ", + U2NAME(ityp, png_type)); set_err(kMinorError); break; } @@ -3198,8 +3275,7 @@ "%s JDAT chunks must be consecutive or interleaved with IDATs\n", verbose? ":":fname); set_err(kMajorError); - if (!force) - return global_error; + return global_error; } } else if (verbose) printf("\n"); @@ -3258,10 +3334,9 @@ printf("\n object ID = %u, image type = %s, delta type = %s\n", SH(buffer), buffer[2]? "PNG":"unspecified", - (dtype < sizeof(delta_type)/sizeof(char *))? - delta_type[dtype] : inv); + U2NAME(dtype, delta_type)); if (sz > 4) { - if (dtype == 5) { + if (dtype == 7) { printf("%s invalid %slength for delta type %d\n", verbose? ":":fname, verbose? "":"DHDR ", dtype); set_err(kMinorError); @@ -3269,7 +3344,7 @@ printf(" block width = %lu, block height = %lu\n", LG(buffer+4), LG(buffer+8)); if (sz > 12) { - if (dtype == 0 || dtype == 5) { + if (dtype == 0) { printf("%s invalid %slength for delta type %d\n", verbose? ":":fname, verbose? "":"DHDR ", dtype); set_err(kMinorError); @@ -3280,7 +3355,7 @@ } } } - have_DHDR = 1; + //have_DHDR = 1; last_is_IDAT = last_is_JDAT = 0; #ifdef USE_ZLIB first_idat = 1; /* flag: next IDAT will be the first in this subimage */ @@ -3300,12 +3375,16 @@ set_err(kMinorError); } else if (sz == 0 && verbose) { printf(": empty\n"); + } else if (sz > BS) { + /* FIXME: large FRAM chunks are unusual, but should be supported */ + printf("%s checking large %schunk not currently supported\n", + verbose? ":":fname, verbose? "":"FRAM "); + set_err(kMinorError); } else if (verbose) { uch fmode = buffer[0]; printf(": mode %d\n %s\n", fmode, - (fmode < sizeof(framing_mode)/sizeof(char *))? - framing_mode[fmode] : inv); + U2NAME(fmode, framing_mode)); if (sz > 1) { uch *p = buffer+1; int bytes_left, found_null=0; @@ -3343,7 +3422,7 @@ set_err(kMinorError); } else { bytes_left -= 4; - printf(" %s\n", change_interframe_delay[cid]); + printf(" %s\n", U2NAME(cid, change_interframe_delay)); /* GRR: need real error-checking here: */ if (cid && bytes_left >= 4) { ulg delay = LG(p); @@ -3353,7 +3432,7 @@ p += 4; bytes_left -= 4; } - printf(" %s\n", change_timeout_and_termination[ctt]); + printf(" %s\n", U2NAME(ctt, change_timeout_and_termination)); /* GRR: need real error-checking here: */ if (ctt && bytes_left >= 4) { ulg val = LG(p); @@ -3366,7 +3445,8 @@ p += 4; bytes_left -= 4; } - printf(" %s\n", change_subframe_clipping_boundaries[cscb]); + printf(" %s\n", + U2NAME(cscb, change_subframe_clipping_boundaries)); /* GRR: need real error-checking here: */ if (cscb && bytes_left >= 17) { printf(" new frame clipping boundaries (%s):\n", (*p++)? @@ -3377,7 +3457,7 @@ p += 16; bytes_left -= 17; } - printf(" %s\n", change_sync_id_list[csil]); + printf(" %s\n", U2NAME(csil, change_sync_id_list)); if (csil) { if (bytes_left) { while (bytes_left >= 4) { @@ -3411,6 +3491,15 @@ } else if (have_SAVE) { printf("%s multiple SAVE not allowed\n", verbose? ":":fname); set_err(kMinorError); + } else if (sz > BS) { + printf("%s invalid %slength\n", /* or input buffer too small */ + verbose? ":":fname, verbose? "":"FRAM "); + set_err(kMinorError); + } else if (sz > BS) { + /* FIXME: large SAVE chunks should be supported */ + printf("%s checking large %schunk not currently supported\n", + verbose? ":":fname, verbose? "":"SAVE "); + set_err(kMinorError); } else if (sz > 0 && verbose) { uch offsize = buffer[0]; @@ -3433,8 +3522,7 @@ set_err(kMinorError); break; } - printf(" entry type = %s", (type < - sizeof(entry_type)/sizeof(char *))? entry_type[type] : inv); + printf(" entry type = %s", U2NAME(type, entry_type)); ++p; if (type <= 1) { ulg first4 = LG(p); @@ -3504,6 +3592,9 @@ } else if (verbose) { printf("\n"); if (sz > 0) { + if (sz >= BS) + sz = BS-1; + buffer[sz] = '\0'; init_printbuf_state(&prbuf_state); print_buffer(&prbuf_state, buffer, sz, 1); report_printbuf(&prbuf_state, fname, chunkid); @@ -3520,6 +3611,9 @@ printf("%s nEED not defined in %cNG\n", verbose? ":":fname, png? 'P':'J'); set_err(kMinorError); + } else if (sz > BS && verbose) { + /* FIXME: large nEED chunks are unusual, but should be supported */ + printf(": printing large chunk not currently supported\n"); } else if (sz > 0 && verbose) { uch *p = buffer; uch *lastbreak = buffer; @@ -3669,8 +3763,7 @@ printf("\n parent object ID = %u, clone object ID = %u\n", SH(buffer), SH(buffer+2)); printf(" clone type = %s, %s, %s\n", - (ct < sizeof(clone_type)/sizeof(char *))? clone_type[ct] : inv, - (dns < sizeof(do_not_show)/sizeof(char *))? do_not_show[dns] : inv, + U2NAME(ct, clone_type), U2NAME(dns, do_not_show), cf? "same concreteness as parent":"abstract"); if (ldt) printf(" difference from parent's position: delta-x = %ld," @@ -3707,8 +3800,7 @@ if (sz > 4) smode = buffer[4]; printf("\n first object = %u, last object = %u\n", first, last); - printf(" %s\n", - (smode < sizeof(show_mode)/sizeof(char *))? show_mode[smode] : inv); + printf(" %s\n", U2NAME(smode, show_mode)); } last_is_IDAT = last_is_JDAT = 0; @@ -3746,11 +3838,16 @@ printf("%s invalid %slength\n", verbose? ":":fname, verbose? "":"LOOP "); set_err(kMajorError); - } - if (verbose && no_err(kMinorError)) { + } else if (sz > BS) { + /* FIXME: large LOOP chunks should be supported */ + printf("%s checking large %schunk not currently supported\n", + verbose? ":":fname, verbose? "":"LOOP "); + set_err(kMinorError); + } else if (verbose && no_err(kMinorError)) { printf(": nest level = %u\n count = %lu, termination = %s\n", (unsigned)(buffer[0]), LG(buffer+1), sz == 5? - termination_condition[0] : termination_condition[buffer[5] & 0x3]); + termination_condition[0] : + U2NAME(buffer[5] & 0x3, termination_condition)); /* GRR: not checking for valid buffer[1] values */ if (sz > 6) { printf(" iteration min = %lu", LG(buffer+6)); @@ -3897,7 +3994,7 @@ if (ityp == 2 || ityp == 4 || ityp == 6) { /* RGB or GA or RGBA */ printf("%s invalid %sbit depth (%d) for %s image\n", verbose? ":":fname, verbose? "":"BASI ", bitdepth, - png_type[ityp]); + U2NAME(ityp, png_type)); set_err(kMinorError); } break; @@ -3907,7 +4004,7 @@ if (ityp == 3) { /* palette */ printf("%s invalid %sbit depth (%d) for %s image\n", verbose? ":":fname, verbose? "":"BASI ", bitdepth, - png_type[ityp]); + U2NAME(ityp, png_type)); set_err(kMinorError); } break; @@ -3931,7 +4028,8 @@ } if (verbose && no_err(kMinorError)) { printf("\n %ld x %ld image, %d-bit %s, %sinterlaced\n", w, h, - bitdepth, (ityp > 6)? png_type[1]:png_type[ityp], lace? "":"non-"); + bitdepth, (ityp > 6)? png_type[1]:U2NAME(ityp, png_type), + lace? "":"non-"); } if (sz > 13) { ush red, green, blue; @@ -3988,7 +4086,7 @@ printf("%s PPLT not defined in %cNG\n", verbose? ":":fname, png? 'P':'J'); set_err(kMinorError); - } else if (sz < 4) { + } else if (sz < 4 || sz > BS) { printf("%s invalid %slength\n", verbose? ":":fname, verbose? "":"PPLT "); set_err(kMinorError); @@ -3997,15 +4095,14 @@ uch dtype = buffer[0]; uch first_idx = buffer[1]; uch last_idx = buffer[2]; - uch *buf = buffer+3; + int base = 3; int bytes_left = sz-3; int samples, npplt = 0, nblks = 0; if (!verbose && printpal && !quiet) printf(" PPLT chunk"); if (verbose) - printf(": %s\n", (dtype < sizeof(pplt_delta_type)/sizeof(char *))? - pplt_delta_type[dtype] : inv); + printf(": %s\n", U2NAME(dtype, pplt_delta_type)); plus = (dtype & 1)? "+" : ""; if (dtype < 2) samples = 3; @@ -4018,27 +4115,37 @@ if (bytes_left < 0) break; ++nblks; - for (i = first_idx; i <= last_idx; ++i, buf += samples) { + for (i = first_idx; i <= last_idx; ++i, base += samples) { + if (sz - samples < base) { + printf("%s implied sample outside %schunk bounds\n", + verbose? ":":fname, verbose? "":"PPLT "); + set_err(kMinorError); + /* break out of outer loop, and suppress additional length error */ + bytes_left = 0; + break; + } ++npplt; if (printpal) { if (samples == 4) printf(" %3d: %s(%3d,%3d,%3d,%3d) = " "%s(0x%02x,0x%02x,0x%02x,0x%02x)\n", i, - plus, buf[0], buf[1], buf[2], buf[3], - plus, buf[0], buf[1], buf[2], buf[3]); + plus, buffer[base + 0], buffer[base + 1], + buffer[base + 2], buffer[base + 3], + plus, buffer[base + 0], buffer[base + 1], + buffer[base + 2], buffer[base + 3]); else if (samples == 3) printf(" %3d: %s(%3d,%3d,%3d) = %s(0x%02x,0x%02x,0x%02x)\n", - i, plus, buf[0], buf[1], buf[2], - plus, buf[0], buf[1], buf[2]); + i, plus, buffer[base + 0], buffer[base + 1], buffer[base + 2], + plus, buffer[base + 0], buffer[base + 1], buffer[base + 2]); else printf(" %3d: %s(%3d) = %s(0x%02x)\n", i, - plus, *buf, plus, *buf); + plus, buffer[base], plus, buffer[base]); } } if (bytes_left > 2) { - first_idx = buf[0]; - last_idx = buf[1]; - buf += 2; + first_idx = buffer[base + 0]; + last_idx = buffer[base + 1]; + base += 2; bytes_left -= 2; } else if (bytes_left) break; @@ -4068,12 +4175,17 @@ printf("%s invalid %slength\n", verbose? ":":fname, verbose? "":"PAST "); set_err(kMajorError); + } else if (sz > BS) { + /* FIXME: large PAST chunks should be supported */ + printf("%s checking large %schunk not currently supported\n", + verbose? ":":fname, verbose? "":"PAST "); + set_err(kMinorError); } else if (buffer[2] > 2) { printf("%s invalid %starget delta type (%u)\n", verbose? ":":fname, verbose? "":"PAST ", buffer[2]); set_err(kMinorError); } - if (no_err(kMinorError)) { + if (no_err(kMinorError) && sz <= BS) { ush dest_id = SH(buffer); uch target_dtype = buffer[2]; long x = LG(buffer+3); @@ -4126,8 +4238,9 @@ if (verbose) { printf(" source ID = %u: composition mode = %s,\n", - src_id, composition_mode[comp_mode]); - printf(" orientation = %s,\n", orientation[orient >> 1]); + src_id, U2NAME(comp_mode, composition_mode)); + printf(" orientation = %s,\n", + U2NAME(orient >> 1, orientation)); printf(" offset = {%ld,%ld} measured from {%ld,%ld} in " "destination image,\n", xoff, yoff, offset_origin? x:0, offset_origin? y:0); @@ -4169,12 +4282,13 @@ set_err(kMinorError); } if (verbose && no_err(kMinorError)) { - printf("\n action = %s\n", termination_action[buffer[0] /* & 3 */]); + printf("\n action = %s\n", + U2NAME(buffer[0] /* & 3 */, termination_action)); if (sz >= 10) { ulg val = LG(buffer+2); printf(" action after iterations = %s\n", - termination_action[buffer[1]]); + U2NAME(buffer[1], termination_action)); printf(" inter-iteration delay = %lu tick%s, max iterations = ", val, (val == 1)? "":"s"); val = LG(buffer+6); @@ -4199,8 +4313,13 @@ printf("%s invalid %slength\n", verbose? ":":fname, verbose? "":"DISC "); set_err(kMajorError); + } else if (sz > BS) { + /* FIXME: large DISC chunks should be supported */ + printf("%s checking large %schunk not currently supported\n", + verbose? ":":fname, verbose? "":"DISC "); + set_err(kMinorError); } - if (verbose && no_err(kMinorError)) { + if (verbose && no_err(kMinorError) && sz <= BS) { if (sz == 0) { printf("\n discard all nonzero objects%s\n", have_SAVE? " except those before SAVE":""); @@ -4274,8 +4393,13 @@ printf("%s invalid %slength\n", verbose? ":":fname, verbose? "":"DROP "); set_err(kMajorError); + } else if (sz > BS) { + /* FIXME: large DROP chunks should be supported */ + printf("%s checking large %schunk not currently supported\n", + verbose? ":":fname, verbose? "":"DROP "); + set_err(kMinorError); } - if (no_err(kMinorError)) { + if (no_err(kMinorError) && sz <= BS) { uch *buf = buffer; int bytes_left = sz; int num_names = 0; @@ -4324,7 +4448,12 @@ verbose? ":":fname); set_err(kMinorError); } - if (no_err(kMinorError)) { + if (sz > BS) { + /* FIXME: large DBYK chunks should be supported */ + printf("%s checking large %schunk not currently supported\n", + verbose? ":":fname, verbose? "":"DBYK "); + set_err(kMinorError); + } else if (no_err(kMinorError)) { uch *buf = buffer + 5; int bytes_left = sz - 5; int first = 1; @@ -4384,7 +4513,12 @@ verbose? ":":fname, verbose? "":"ORDR "); set_err(kMajorError); } - if (no_err(kMinorError)) { + if (sz > BS) { + /* FIXME: large ORDR chunks should be supported */ + printf("%s checking large %schunk not currently supported\n", + verbose? ":":fname, verbose? "":"ORDR "); + set_err(kMinorError); + } else if (no_err(kMinorError)) { uch *buf = buffer; int bytes_left = sz; @@ -4407,7 +4541,7 @@ if (!no_err(kMinorError)) break; if (verbose) - printf(" %.*s: %s\n", 4, buf, order_type[buf[4]]); + printf(" %.*s: %s\n", 4, buf, U2NAME(buf[4], order_type)); buf += 5; bytes_left -= 5; } @@ -4481,10 +4615,11 @@ else printf("s = %u to %u\n", first, last); if (xmeth == ymeth) - printf(" method = %s\n", magnification_method[xmeth]); + printf(" method = %s\n", U2NAME(xmeth, magnification_method)); else printf(" X method = %s\n Y method = %s\n", - magnification_method[xmeth], magnification_method[ymeth]); + U2NAME(xmeth, magnification_method), + U2NAME(ymeth, magnification_method)); printf(" X mag = %u, left mag = %u, right mag = %u\n", mx, ml, mr); printf(" Y mag = %u, top mag = %u, bottom mag = %u\n", @@ -4599,15 +4734,9 @@ if (no_err(kMinorError) && fpOut != NULL) putlong(fpOut, CRCCOMPL(crc)); - - } else if (force) { - /* force may result in set_err(kMajorError) or more upstream, and failing - * to read CRC bytes here guarantees immediate downstream error when - * attempting to read length bytes and chunk type/name bytes */ - filecrc = getlong(fp, fname, "CRC value"); } - if (global_error > kWarning && !force) + if (global_error > kWarning) return global_error; } @@ -4683,13 +4812,13 @@ printf("%s: %s%s%s (%ldx%ld, %d-bit %s%s%s, %s%d.%d%%).\n", global_error? brief_warn : brief_OK, color? COLOR_YELLOW:"", fname, color? COLOR_NORMAL:"", - w, h, jbitd, and, jng_type[jtyp], + w, h, jbitd, and, U2NAME(jtyp, jng_type), lace? ", progressive":"", sgn, cfactor/10, cfactor%10); else printf("%s: %s%s%s (%ldx%ld, %d-bit %s%s + %d-bit alpha%s, %s%d.%d%%)" ".\n", global_error? brief_warn : brief_OK, color? COLOR_YELLOW:"", fname, color? COLOR_NORMAL:"", - w, h, jbitd, and, jng_type[jtyp-2], + w, h, jbitd, and, U2NAME(jtyp-2, jng_type), alphadepth, lace? ", progressive":"", sgn, cfactor/10, cfactor%10); } @@ -4715,7 +4844,7 @@ printf("%s: %s%s%s (%ldx%ld, %d-bit %s%s, %sinterlaced, %s%d.%d%%).\n", global_error? brief_warn : brief_OK, color? COLOR_YELLOW:"", fname, color? COLOR_NORMAL:"", - w, h, bitdepth, (ityp > 6)? png_type[1] : png_type[ityp], + w, h, bitdepth, (ityp > 6)? png_type[1] : U2NAME(ityp, png_type), (ityp == 3 && have_tRNS)? "+trns" : "", lace? "" : "non-", sgn, cfactor/10, cfactor%10); } @@ -4837,8 +4966,7 @@ const uch *good_magic = (which == 0)? good_PNG_magic : ((which == 1)? good_MNG_magic : good_JNG_magic); - for (i = 1; i < 3; ++i) - { + for (i = 1; i <= 3; ++i) { if (magic[i] != good_magic[i]) { return 2; } @@ -4895,8 +5023,10 @@ /* GRR 20061203: now EBCDIC-safe */ int check_chunk_name(char *chunk_name, char *fname) { - if (isASCIIalpha((int)chunk_name[0]) && isASCIIalpha((int)chunk_name[1]) && - isASCIIalpha((int)chunk_name[2]) && isASCIIalpha((int)chunk_name[3])) + if (isASCIIalpha((int)(uch)chunk_name[0]) && + isASCIIalpha((int)(uch)chunk_name[1]) && + isASCIIalpha((int)(uch)chunk_name[2]) && + isASCIIalpha((int)(uch)chunk_name[3])) return 0; printf("%s%s invalid chunk name \"%.*s\" (%02x %02x %02x %02x)\n", @@ -4999,7 +5129,7 @@ int check_ascii_float(uch *buffer, int len, char *chunkid, char *fname) { uch *qq = buffer, *bufEnd = buffer + len; - int have_sign = 0, have_integer = 0, have_dot = 0, have_fraction = 0; + int /* have_sign = 0, */ have_integer = 0, have_dot = 0, have_fraction = 0; int have_E = 0, have_Esign = 0, have_exponent = 0, in_digits = 0; int have_nonzero = 0; int rc = 0; @@ -5009,7 +5139,7 @@ case '+': case '-': if (qq == buffer) { - have_sign = 1; + //have_sign = 1; in_digits = 0; } else if (have_E && !have_Esign) { have_Esign = 1; @@ -5099,3 +5229,8 @@ return rc; } + +char const * u2name_helper(unsigned int value, const char **names, + size_t nnames) { + return (value < nnames) ? names[value] : inv; +}