Here is an update to jbigkit 2.2.
Changes in version 2.2 (2026-10-09)
This release fixes a number of robustness problems in both the library
and the command-line converters. Users who process BIE or PBM/PGM data
from untrusted sources should upgrade.
- pbmtojbg and pbmtojbg85 now bound the width, height and maxval
read from a PBM/PGM header, and check the size calculations that
follow for integer overflow. Previously a crafted header could
make them allocate a truncated buffer and then write past its end.
- The jbig.c decoder will now, by default, return JBG_ENOMEM if the
final image layer would occupy more than two gigabytes. Users can
adjust this limit by changing sd->maxmem right after having called
jbg_dec_init(&sd). This is to reduce the risk of denial-of-service
attacks through excessive image dimensions (e.g., CVE-2017-9937).
- jbg_newlen() now checks for the end of the data before reading a
marker code and within a NEWLEN marker segment
- fixed a typo in the jbg85_dec_finalheight() macro, which tested a
misspelled JBG_VLENGHT instead of JBG_VLENGTH
- jbg_enc_options() now tests the mx argument rather than my against
the permitted range
- jbgtopbm no longer divides by zero when option -d is applied to a
BIE with an invalid BIH
- pbmtojbg and jbgtopbm now open the output file only after the input
file has been read completely, so that converting a file onto
itself no longer destroys it
- jbgtopbm85 now writes its progress messages to stderr, so that
option -y no longer corrupts a PBM image written to standard output
- pbmtojbg now aborts with an error message if the chosen combination
of layer and stripe options encoded nothing, rather than silently
leaving an empty output file behind
- pbmtojbg and pbmtojbg85 now accept an ASCII PBM/PGM file whose
final value is not followed by white space
- "jbgtopbm -d" now also calculates the uncompressed image size
- the Makefile uses $(MAKE) and $(LDFLAGS) in more places
- the contrib directory, which held Atari ST project files
contributed in 1996, has been removed
- Polish translation PO file contributed by Jakub Bogusz
- numerous corrections to comments and documentation
Tested on aarch64.
Index: Makefile
===================================================================
RCS file: /cvs/ports/graphics/jbigkit/Makefile,v
retrieving revision 1.48
diff -u -p -u -p -r1.48 Makefile
--- Makefile 26 Sep 2023 11:39:05 -0000 1.48
+++ Makefile 29 Nov 2026 02:17:01 -0000
@@ -1,25 +1,26 @@
COMMENT = lossless image compression library, with lightweight version
-DISTNAME = jbigkit-2.1
-REVISION = 0
+DISTNAME = jbigkit-2.2
SHARED_LIBS += jbig 3.0 # 2.0
SHARED_LIBS += jbig85 3.0 # 2.0
CATEGORIES = graphics
-HOMEPAGE = http://www.cl.cam.ac.uk/~mgk25/jbigkit/
+HOMEPAGE = https://www.cl.cam.ac.uk/~mgk25/jbigkit/
# GPLv2+
PERMIT_PACKAGE = Yes
WANTLIB += c
-SITES = http://www.cl.cam.ac.uk/~mgk25/download/
+SITES = ${HOMEPAGE}download/
MAKE_FLAGS = CC="${CC}" CFLAGS="${CFLAGS} -Wall" \
VERSION="${LIBjbig_VERSION}"
MAKE_ENV = LD_LIBRARY_PATH="${WRKSRC}/libjbig"
+
+USE_GMAKE = Yes
do-install:
${INSTALL_MAN_DIR} ${PREFIX}/man/man1
Index: distinfo
===================================================================
RCS file: /cvs/ports/graphics/jbigkit/distinfo,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 distinfo
--- distinfo 8 Apr 2014 13:59:32 -0000 1.7
+++ distinfo 29 Nov 2026 02:17:01 -0000
@@ -1,2 +1,2 @@
-SHA256 (jbigkit-2.1.tar.gz) = 3nEGtr+vSV1oZcfdesbKE4G9EuDYFAXqgefyFnJj2TI=
-SIZE (jbigkit-2.1.tar.gz) = 438710
+SHA256 (jbigkit-2.2.tar.gz) = MwIQnJO3vvv/o8/ovOtDVfGd6g7n3LXzNxCxZIv2ZFw=
+SIZE (jbigkit-2.2.tar.gz) = 441594
Index: patches/patch-Makefile
===================================================================
RCS file: /cvs/ports/graphics/jbigkit/patches/patch-Makefile,v
retrieving revision 1.6
diff -u -p -u -p -r1.6 patch-Makefile
--- patches/patch-Makefile 11 Mar 2022 19:22:35 -0000 1.6
+++ patches/patch-Makefile 29 Nov 2026 02:17:01 -0000
@@ -1,11 +1,12 @@
---- Makefile.orig Tue Apr 8 14:41:53 2014
-+++ Makefile Tue Apr 8 14:42:35 2014
+Index: Makefile
+--- Makefile.orig
++++ Makefile
@@ -7,8 +7,6 @@ CC = gcc
- CFLAGS = -O2 -W -Wno-unused-result
- # CFLAGS = -O -g -W -Wall -Wno-unused-result -ansi -pedantic # -DDEBUG
+ CFLAGS = -O2 -W
+ # CFLAGS = -O -g -W -Wall -ansi -pedantic # -DDEBUG
-export CC CFLAGS
-
- VERSION=2.1
+ VERSION=2.2
all: lib pbm
Index: patches/patch-libjbig_Makefile
===================================================================
RCS file: /cvs/ports/graphics/jbigkit/patches/patch-libjbig_Makefile,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 patch-libjbig_Makefile
--- patches/patch-libjbig_Makefile 11 Mar 2022 19:22:35 -0000 1.10
+++ patches/patch-libjbig_Makefile 29 Nov 2026 02:17:01 -0000
@@ -1,57 +1,46 @@
---- libjbig/Makefile.orig Thu Mar 27 19:47:15 2014
-+++ libjbig/Makefile Thu Mar 10 21:49:56 2016
+Index: libjbig/Makefile
+--- libjbig/Makefile.orig
++++ libjbig/Makefile
@@ -6,8 +6,10 @@ CC = gcc
# Options for the compiler: A high optimization level is suggested
CFLAGS = -g -O -W -Wall -ansi -pedantic # --coverage
--all: libjbig.a libjbig85.a tstcodec tstcodec85
-+PICFLAG= -fpic
+-all: libjbig.a libjbig85.a tstcodec tstcodec85 tstjoint
++PICFLAG= -fPIC
-+all: libjbig.a libjbig.so.$(VERSION) libjbig85.a libjbig85.so.$(VERSION)
tstcodec tstcodec85
++all: libjbig.a libjbig.so.$(VERSION) libjbig85.a libjbig85.so.$(VERSION)
tstcodec tstcodec85 tstjoint
+
tstcodec: tstcodec.o jbig.o jbig_ar.o
- $(CC) $(CFLAGS) -o tstcodec tstcodec.o jbig.o jbig_ar.o
+ $(CC) $(LDFLAGS) $(CFLAGS) -o tstcodec tstcodec.o jbig.o jbig_ar.o
-@@ -15,15 +17,28 @@ tstcodec85: tstcodec85.o jbig85.o jbig_ar.o
- $(CC) $(CFLAGS) -o tstcodec85 tstcodec85.o jbig85.o jbig_ar.o
-
- libjbig.a: jbig.o jbig_ar.o
-- rm -f libjbig.a
-- ar rc libjbig.a jbig.o jbig_ar.o
-- -ranlib libjbig.a
-+ rm -f ${.TARGET}
-+ ar rc ${.TARGET} ${.ALLSRC}
-+ -ranlib ${.TARGET}
+@@ -18,11 +20,24 @@ tstjoint: tstjoint.o jbig.o jbig85.o jbig_ar.o
+ $(CC) $(LDFLAGS) $(CFLAGS) -o tstjoint \
+ tstjoint.o jbig.o jbig85.o jbig_ar.o
+libjbig.so.$(VERSION): jbig.so jbig_ar.so
-+ rm -f ${.TARGET}
-+ ${CC} -shared $(PICFLAG) -o ${.TARGET} ${.ALLSRC}
++ rm -f $@
++ $(CC) -shared $(PICFLAG) -o $@ jbig.so jbig_ar.so
+
- libjbig85.a: jbig85.o jbig_ar.o
-- rm -f libjbig85.a
-- ar rc libjbig85.a jbig85.o jbig_ar.o
-- -ranlib libjbig85.a
-+ rm -f ${.TARGET}
-+ ar rc ${.TARGET} ${.ALLSRC}
-+ -ranlib ${.TARGET}
+ libjbig.a: jbig.o jbig_ar.o
+ rm -f libjbig.a
+ ar rc libjbig.a jbig.o jbig_ar.o
+ -ranlib libjbig.a
+libjbig85.so.$(VERSION): jbig85.so jbig_ar.so
-+ rm -f ${.TARGET}
-+ ${CC} -shared $(PICFLAG) -o ${.TARGET} ${.ALLSRC}
++ rm -f $@
++ $(CC) -shared $(PICFLAG) -o $@ jbig85.so jbig_ar.so
+
+.SUFFIXES: .o .so
+
+.c.so:
-+ ${CC} ${CFLAGS} $(PICFLAG) -c ${.IMPSRC} -o ${.TARGET}
++ $(CC) $(CFLAGS) $(PICFLAG) -c $< -o $@
+
- jbig.o: jbig.c jbig.h jbig_ar.h
- jbig85.o: jbig85.c jbig85.h jbig_ar.h
- jbig_ar.o: jbig_ar.c jbig_ar.h
-@@ -50,6 +65,5 @@ t82test.pbm: tstcodec
- ./tstcodec $@
-
+ libjbig85.a: jbig85.o jbig_ar.o
+ rm -f libjbig85.a
+ ar rc libjbig85.a jbig85.o jbig_ar.o
+@@ -57,4 +72,5 @@ t82test.pbm: tstcodec
clean:
-- rm -f *.o *.gcda *.gcno *.gcov *.plist *~ core gmon.out dbg_d\=??.pbm
-- rm -f t82test.pbm
-+ rm -f *.{o,gcda,gcno,gcov} *~ core gmon.out dbg_d\=??.pbm
libjbig.so.$(VERSION) libjbig85.so.$(VERSION)
- rm -f tstcodec tstcodec85
+ rm -f *.o *.gcda *.gcno *.gcov *.plist *~ core gmon.out dbg_d\=??.pbm
+ rm -f t82test.pbm
++ rm -f *.so libjbig.so.$(VERSION) libjbig85.so.$(VERSION)
+ rm -f tstcodec tstcodec85 tstjoint
Index: patches/patch-pbmtools_Makefile
===================================================================
RCS file: /cvs/ports/graphics/jbigkit/patches/patch-pbmtools_Makefile,v
retrieving revision 1.6
diff -u -p -u -p -r1.6 patch-pbmtools_Makefile
--- patches/patch-pbmtools_Makefile 11 Mar 2022 19:22:35 -0000 1.6
+++ patches/patch-pbmtools_Makefile 29 Nov 2026 02:17:01 -0000
@@ -1,23 +1,12 @@
---- pbmtools/Makefile.orig Thu Mar 27 18:47:15 2014
-+++ pbmtools/Makefile Tue Apr 8 14:54:55 2014
-@@ -10,7 +10,7 @@ CPPFLAGS = -I../libjbig
- .SUFFIXES: .1 .5 .txt $(SUFFIXES)
- .PHONY: txt test test82 test85 clean
+Index: pbmtools/Makefile
+--- pbmtools/Makefile.orig
++++ pbmtools/Makefile
+@@ -12,7 +12,7 @@ LDFLAGS = -L../libjbig
+
+ .PHONY: txt pdf test test82 test85 clean
-all: pbmtojbg jbgtopbm pbmtojbg85 jbgtopbm85 txt
+all: pbmtojbg jbgtopbm pbmtojbg85 jbgtopbm85
txt: pbmtojbg.txt jbgtopbm.txt pbm.txt pgm.txt
-@@ -111,8 +111,11 @@ test85: pbmtojbg jbgtopbm pbmtojbg85 jbgtopbm85 test-t
- make IMG=t82 "OPTIONSP=-Y -1 1920" dotest85
- make IMG=t82 "OPTIONSP=-Y -1 1949" dotest85
- make IMG=t82 "OPTIONSP=-Y -1 1950" dotest85
-+ make IMG=ccitt1 dotest1
- make IMG=ccitt1 dotest85
-+ make IMG=ccitt2 dotest1
- make IMG=ccitt2 dotest85
-+ make IMG=ccitt3 dotest1
- make IMG=ccitt3 dotest85
- rm -f test-*.jbg test-*.jbg85 test-*.pbm
- @echo
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/graphics/jbigkit/pkg/PLIST,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 PLIST
--- pkg/PLIST 11 Mar 2022 19:22:35 -0000 1.8
+++ pkg/PLIST 29 Nov 2026 02:17:01 -0000
@@ -3,9 +3,9 @@
include/jbig.h
include/jbig85.h
include/jbig_ar.h
-lib/libjbig.a
+@static-lib lib/libjbig.a
@lib lib/libjbig.so.${LIBjbig_VERSION}
-lib/libjbig85.a
+@static-lib lib/libjbig85.a
@lib lib/libjbig85.so.${LIBjbig85_VERSION}
@man man/man1/jbgtopbm.1
@man man/man1/pbmtojbg.1