diff -ruN netpbm-10.81.02-orig/Makefile.config.fink netpbm-10.81.02/Makefile.config.fink
--- netpbm-10.81.02-orig/Makefile.config.fink	1969-12-31 18:00:00.000000000 -0600
+++ netpbm-10.81.02/Makefile.config.fink	2018-01-26 21:50:38.000000000 -0600
@@ -0,0 +1,31 @@
+#
+# Configuration for fink
+# Copied from a manual run of ./configure (plus some additions)
+
+DEFAULT_TARGET	= nonmerge
+NETPBMLIBTYPE	= dylib
+NETPBMLIBSUFFIX	= dylib
+STATICLIB_TOO	= n
+NETPBMLIB_RUNTIME_PATH = @PREFIX@/lib
+CC		= cc -no-cpp-precomp
+CFLAGS = -O3 -ffast-math  -pedantic -fno-common -Wall -Wno-uninitialized -Wmissing-declarations -Wimplicit -Wwrite-strings -Wmissing-prototypes -Wundef -Wno-unknown-pragmas -MD -Wno-error=implicit-function-declaration
+CFLAGS_SHLIB	= -fno-common
+LDSHLIB		= -dynamiclib -install_name $(NETPBMLIB_RUNTIME_PATH)/libnetpbm.$(MAJ).dylib -compatibility_version $$(($(MAJ)+1)) -current_version $$(($(MAJ)+1)).$(MIN)
+LINKERISCOMPILER	= Y
+CFLAGS_SHLIB	+= -fPIC
+TIFFLIB		= libtiff.dylib
+JPEGLIB		= @PREFIX@/lib/libjpeg8.2-turbo/lib/libjpeg.8.dylib
+PNGLIB		= libpng.dylib
+ZLIB		= libz.dylib
+JBIGLIB		= libjbig.dylib
+JASPERLIB       = libjasper.dylib
+TIFFHDR_DIR	= @PREFIX@/include
+JPEGHDR_DIR	= @PREFIX@/lib/libjpeg8.2-turbo/include
+PNGHDR_DIR	= @PREFIX@/include
+ZHDR_DIR	= @PREFIX@/include
+JBIGHDR_DIR	= @PREFIX@/include
+JASPERHDR_DIR	= @PREFIX@/include
+PKGMANDIR	= share/man
+NETPBM_DOCURL	= file:@PREFIX@/share/doc/netpbm
+WANT_SSE	= Y
+RGB_DB_PATH	= @PREFIX@/share/netpbm/rgb.txt:/opt/X11/share/X11/rgb.txt:/usr/lib/X11/rgb.txt:/usr/X11/share/X11/rgb.txt:/usr/X11R6/lib/X11/rgb.txt
diff -ruN netpbm-10.81.02-orig/buildtools/installnetpbm.pl netpbm-10.81.02/buildtools/installnetpbm.pl
--- netpbm-10.81.02-orig/buildtools/installnetpbm.pl	2018-01-25 19:43:30.000000000 -0600
+++ netpbm-10.81.02/buildtools/installnetpbm.pl	2018-01-26 21:45:45.000000000 -0600
@@ -182,7 +182,7 @@
     } elsif ($ENV{OSTYPE} && $ENV{OSTYPE} eq "msdosdjgpp") {
         $default = "/dev/env/DJDIR";
     } else {
-        $default = "/usr/local/netpbm";
+        $default = "@PREFIX@";
     }
 
     my $response = fsObjPrompt("install prefix", $default);
diff -ruN netpbm-10.81.02-orig/buildtools/manpage.mk netpbm-10.81.02/buildtools/manpage.mk
--- netpbm-10.81.02-orig/buildtools/manpage.mk	2018-01-25 19:43:30.000000000 -0600
+++ netpbm-10.81.02/buildtools/manpage.mk	2018-01-26 21:47:08.000000000 -0600
@@ -171,9 +171,9 @@
 .PHONY : installman
 installman: report
 	set -x
-	for f in $(wildcard $(MAN1)); do if [ -f $$f ]; then gzip <$$f >$(MANDIR)/man1/$$f.gz; fi; done
-	for f in $(wildcard $(MAN3)); do if [ -f $$f ]; then gzip <$$f >$(MANDIR)/man3/$$f.gz; fi; done
-	for f in $(wildcard $(MAN5)); do if [ -f $$f ]; then gzip <$$f >$(MANDIR)/man5/$$f.gz; fi; done
+	for f in $(wildcard $(MAN1)); do install -d -m 0755 $(MANDIR)/man1; if [ -f $$f ]; then gzip <$$f >$(MANDIR)/man1/$$f.gz; fi; done
+	for f in $(wildcard $(MAN3)); do install -d -m 0755 $(MANDIR)/man3; if [ -f $$f ]; then gzip <$$f >$(MANDIR)/man3/$$f.gz; fi; done
+	for f in $(wildcard $(MAN5)); do install -d -m 0755 $(MANDIR)/man5; if [ -f $$f ]; then gzip <$$f >$(MANDIR)/man5/$$f.gz; fi; done
 
 
 # This will uninstall the man pages.
diff -ruN netpbm-10.81.02-orig/converter/other/pnmtopng.c netpbm-10.81.02/converter/other/pnmtopng.c
--- netpbm-10.81.02-orig/converter/other/pnmtopng.c	2018-01-25 19:43:29.000000000 -0600
+++ netpbm-10.81.02/converter/other/pnmtopng.c	2018-01-26 21:45:45.000000000 -0600
@@ -558,7 +558,7 @@
                       unsigned int * const bestMatchP) {
     
     unsigned int paletteIndex;
-    unsigned int bestIndex;
+    unsigned int bestIndex = 0;
     unsigned int bestMatch;
 
     assert(paletteSize > 0);
@@ -1627,9 +1627,9 @@
     colorhist_vector chv;
     unsigned int colors;
 
-    gray * alphas_of_color[MAXPALETTEENTRIES];
+    gray * alphas_of_color[MAXPALETTEENTRIES + 1];
     unsigned int alphas_first_index[MAXPALETTEENTRIES];
-    unsigned int alphas_of_color_cnt[MAXPALETTEENTRIES];
+    unsigned int alphas_of_color_cnt[MAXPALETTEENTRIES + 1];
 
     getChv(ifP, rasterPos, cols, rows, maxval, format, MAXCOLORS,
            &chv, &colors);
@@ -2691,7 +2691,7 @@
         /* The color part of the color/alpha palette passed to the PNG
            compressor 
         */
-    unsigned int paletteSize;
+    unsigned int paletteSize = MAXCOLORS;
 
     gray transPnm[MAXCOLORS];
     png_byte  trans[MAXCOLORS];
