rename from libjbig to jbigkit; apply well known patches [release 2.1-2mamba;Fri Nov 29 2024]

This commit is contained in:
Silvan Calarco 2024-11-29 16:12:01 +01:00
parent c953802f42
commit 4e85f20176
8 changed files with 578 additions and 0 deletions

View File

@ -1,2 +1,4 @@
# jbigkit # jbigkit
Data compression library/utilities for bi-level high-resolution images.

View File

@ -0,0 +1,77 @@
diff -up jbigkit-2.1/pbmtools/pbmtojbg85.c.warnings jbigkit-2.1/pbmtools/pbmtojbg85.c
--- jbigkit-2.1/pbmtools/pbmtojbg85.c.warnings 2008-08-26 00:26:39.000000000 +0200
+++ jbigkit-2.1/pbmtools/pbmtojbg85.c 2012-07-17 16:24:56.741332942 +0200
@@ -72,9 +72,12 @@ static unsigned long getint(FILE *f)
while ((c = getc(f)) != EOF && !(c == 13 || c == 10)) ;
if (c != EOF) {
ungetc(c, f);
- fscanf(f, "%lu", &i);
+ if (fscanf(f, "%lu", &i) != 1) {
+ /* should never fail, since c must be a digit */
+ fprintf(stderr, "Unexpected failure reading digit '%c'\n", c);
+ exit(1);
+ }
}
-
return i;
}
@@ -239,7 +242,9 @@ int main (int argc, char **argv)
break;
case '4':
/* PBM raw binary format */
- fread(next_line, bpl, 1, fin);
+ if (fread(next_line, bpl, 1, fin) != 1) {
+ /* silence compiler warnings; ferror/feof checked below */
+ }
break;
default:
fprintf(stderr, "Unsupported PBM type P%c!\n", type);
diff -up jbigkit-2.1/pbmtools/pbmtojbg.c.warnings jbigkit-2.1/pbmtools/pbmtojbg.c
--- jbigkit-2.1/pbmtools/pbmtojbg.c.warnings 2008-07-16 22:59:41.000000000 +0200
+++ jbigkit-2.1/pbmtools/pbmtojbg.c 2012-07-17 16:23:46.584285686 +0200
@@ -88,7 +88,11 @@ static unsigned long getint(FILE *f)
while ((c = getc(f)) != EOF && !(c == 13 || c == 10)) ;
if (c != EOF) {
ungetc(c, f);
- fscanf(f, "%lu", &i);
+ if (fscanf(f, "%lu", &i) != 1) {
+ /* should never fail, since c must be a digit */
+ fprintf(stderr, "Unexpected failure reading digit '%c'\n", c);
+ exit(1);
+ }
}
return i;
@@ -302,7 +306,9 @@ int main (int argc, char **argv)
break;
case '4':
/* PBM raw binary format */
- fread(bitmap[0], bitmap_size, 1, fin);
+ if (fread(bitmap[0], bitmap_size, 1, fin) != 1) {
+ /* silence compiler warnings; ferror/feof checked below */
+ }
break;
case '2':
case '5':
@@ -314,8 +320,18 @@ int main (int argc, char **argv)
for (j = 0; j < bpp; j++)
image[x * bpp + (bpp - 1) - j] = v >> (j * 8);
}
- } else
- fread(image, width * height, bpp, fin);
+ } else {
+ if (fread(image, width * height, bpp, fin) != (size_t) bpp) {
+ if (ferror(fin)) {
+ fprintf(stderr, "Problem while reading input file '%s", fnin);
+ perror("'");
+ exit(1);
+ } else {
+ fprintf(stderr, "Unexpected end of input file '%s'!\n", fnin);
+ exit(1);
+ }
+ }
+ }
jbg_split_planes(width, height, planes, encode_planes, image, bitmap,
use_graycode);
free(image);

View File

@ -0,0 +1,30 @@
diff --git a/libjbig/jbig.c b/libjbig/jbig.c
index 751ceff..3c76e07 100644
--- a/libjbig/jbig.c
+++ b/libjbig/jbig.c
@@ -889,7 +889,7 @@ void jbg_enc_options(struct jbg_enc_state *s, int order, int options,
if (order >= 0 && order <= 0x0f) s->order = order;
if (options >= 0) s->options = options;
if (l0 > 0) s->l0 = l0;
- if (mx >= 0 && my < 128) s->mx = mx;
+ if (mx >= 0 && mx < 128) s->mx = mx;
if (my >= 0 && my < 256) s->my = my;
return;
diff --git a/pbmtools/Makefile b/pbmtools/Makefile
index 85e1783..6ae2d33 100644
--- a/pbmtools/Makefile
+++ b/pbmtools/Makefile
@@ -56,9 +56,9 @@ test82: pbmtojbg jbgtopbm
make IMG=sandra "OPTIONSP=-o 2" OPTIONSJ= dotest2g
make IMG=multi OPTIONSP= OPTIONSJ= dotest2g
make IMG=multi OPTIONSP=-b OPTIONSJ=-b dotest2g
- make IMG=mx "OPTIONSP=-q -s 3 -m 128" dotest1
- make IMG=mx "OPTIONSP=-q -s 3 -m 128" dotest2b
- make IMG=mx "OPTIONSP=-q -s 3 -m 128 -p 92" dotest2b
+ make IMG=mx "OPTIONSP=-q -s 3 -m 127" dotest1
+ make IMG=mx "OPTIONSP=-q -s 3 -m 127" dotest2b
+ make IMG=mx "OPTIONSP=-q -s 3 -m 127 -p 92" dotest2b
make IMG=mx "OPTIONSP=-q -Y -1" dotest2b
make IMG=mx "OPTIONSP=-Y -1" dotest2b
rm -f test-*.jbg test-*.pbm test-*.pgm

View File

@ -0,0 +1,28 @@
From 7d3c1bea895d910907e2501fe9165e353eceabae Mon Sep 17 00:00:00 2001
From: Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
Date: Mon, 15 Feb 2021 18:27:47 +0000
Subject: [PATCH 15/15] jbg_newlen(): check for end-of-file within
MARKER_NEWLEN
fixes https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=969593
reported by Casper Sun
---
libjbig/jbig.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libjbig/jbig.c b/libjbig/jbig.c
index e9938e5..289b6d8 100644
--- a/libjbig/jbig.c
+++ b/libjbig/jbig.c
@@ -3272,6 +3272,8 @@ int jbg_newlen(unsigned char *bie, size_t len)
else if (p[0] == MARKER_ESC)
switch (p[1]) {
case MARKER_NEWLEN:
+ if (p + 5 >= bie + len)
+ return JBG_EAGAIN;
y = (((long) bie[ 8] << 24) | ((long) bie[ 9] << 16) |
((long) bie[10] << 8) | (long) bie[11]);
yn = (((long) p[2] << 24) | ((long) p[3] << 16) |
--
2.45.0

51
jbigkit-2.1-ldflags.patch Normal file
View File

@ -0,0 +1,51 @@
diff -up jbigkit-2.1/libjbig/Makefile.ldflags jbigkit-2.1/libjbig/Makefile
--- jbigkit-2.1/libjbig/Makefile.ldflags 2018-02-27 17:50:15.786038149 +0100
+++ jbigkit-2.1/libjbig/Makefile 2018-02-27 17:55:44.042093437 +0100
@@ -10,19 +10,19 @@ PICFLAGS := -fPIC -DPIC
all: libjbig.so.$(VERSION) tstcodec tstcodec85
tstcodec: tstcodec.o libjbig.so
- $(CC) $(CFLAGS) -o tstcodec $< -L. -ljbig
+ $(CC) $(CFLAGS) -o tstcodec $< -L. -ljbig $(LDFLAGS)
tstcodec85: tstcodec85.o libjbig85.so
- $(CC) $(CFLAGS) -o tstcodec85 $< -L. -ljbig85
+ $(CC) $(CFLAGS) -o tstcodec85 $< -L. -ljbig85 $(LDFLAGS)
%.so: %.so.$(VERSION)
ln -sf $< $@
libjbig.so.$(VERSION): jbig.o jbig_ar.o
- $(CC) $(CFLAGS) -shared -Wl,-soname,$@ -o $@ $^
+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname,$@ -o $@ $^
libjbig85.so.$(VERSION): jbig85.o jbig_ar.o
- $(CC) $(CFLAGS) -shared -Wl,-soname,$@ -o $@ $^
+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname,$@ -o $@ $^
jbig.o jbig85.o jbig_ar.o: CFLAGS += $(PICFLAGS)
diff -up jbigkit-2.1/pbmtools/Makefile.ldflags jbigkit-2.1/pbmtools/Makefile
--- jbigkit-2.1/pbmtools/Makefile.ldflags 2018-02-27 17:50:35.902857687 +0100
+++ jbigkit-2.1/pbmtools/Makefile 2018-02-27 17:57:09.296328639 +0100
@@ -15,16 +15,16 @@ all: pbmtojbg jbgtopbm pbmtojbg85 jbgtop
txt: pbmtojbg.txt jbgtopbm.txt pbm.txt pgm.txt
pbmtojbg: pbmtojbg.o ../libjbig/libjbig.so
- $(CC) $(CFLAGS) -o pbmtojbg pbmtojbg.o -L../libjbig -ljbig
+ $(CC) $(CFLAGS) -o pbmtojbg pbmtojbg.o -L../libjbig -ljbig $(LDFLAGS)
jbgtopbm: jbgtopbm.o ../libjbig/libjbig.so
- $(CC) $(CFLAGS) -o jbgtopbm jbgtopbm.o -L../libjbig -ljbig
+ $(CC) $(CFLAGS) -o jbgtopbm jbgtopbm.o -L../libjbig -ljbig $(LDFLAGS)
pbmtojbg85: pbmtojbg85.o ../libjbig/libjbig85.so
- $(CC) $(CFLAGS) -o pbmtojbg85 pbmtojbg85.o -L../libjbig -ljbig85
+ $(CC) $(CFLAGS) -o pbmtojbg85 pbmtojbg85.o -L../libjbig -ljbig85 $(LDFLAGS)
jbgtopbm85: jbgtopbm85.o ../libjbig/libjbig85.so
- $(CC) $(CFLAGS) -o jbgtopbm85 jbgtopbm85.o -L../libjbig -ljbig85
+ $(CC) $(CFLAGS) -o jbgtopbm85 jbgtopbm85.o -L../libjbig -ljbig85 $(LDFLAGS)
jbgtopbm.o: jbgtopbm.c ../libjbig/jbig.h
pbmtojbg.o: pbmtojbg.c ../libjbig/jbig.h

View File

@ -0,0 +1,113 @@
From bc3293299bc4981e83b7f37f3615a6b9b27b6837 Mon Sep 17 00:00:00 2001
From: Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
Date: Mon, 3 Aug 2020 21:09:39 +0100
Subject: [PATCH 13/15] new jbig.c limit s->maxmem: maximum decoded image size
(default: 2 GB)
this helps users to reduce denial-of-service risks, as in CVE-2017-9937
---
CHANGES | 9 +++++++++
libjbig/jbig.c | 5 +++++
libjbig/jbig.h | 2 ++
libjbig/jbig.txt | 39 ++++++++++++++++++++++++++++-----------
4 files changed, 44 insertions(+), 11 deletions(-)
diff --git a/libjbig/jbig.c b/libjbig/jbig.c
index fe54946..e9938e5 100644
--- a/libjbig/jbig.c
+++ b/libjbig/jbig.c
@@ -2051,6 +2051,7 @@ void jbg_dec_init(struct jbg_dec_state *s)
s->xmax = 4294967295UL;
s->ymax = 4294967295UL;
s->dmax = 256;
+ s->maxmem = 2000000000; /* no final image larger than 2 GB by default */
s->s = NULL;
return;
@@ -2640,6 +2641,10 @@ int jbg_dec_in(struct jbg_dec_state *s, unsigned char *data, size_t len,
return JBG_EIMPL | 5;
s->options = s->buffer[19];
+ /* will the final image require more bytes than permitted by s->maxmem? */
+ if (s->maxmem / s->planes / s->yd / jbg_ceil_half(s->xd, 3) == 0)
+ return JBG_ENOMEM; /* increase s->maxmem if needed */
+
/* calculate number of stripes that will be required */
s->stripes = jbg_stripes(s->l0, s->yd, s->d);
diff --git a/libjbig/jbig.h b/libjbig/jbig.h
index 81c1adc..2577399 100644
--- a/libjbig/jbig.h
+++ b/libjbig/jbig.h
@@ -181,6 +181,8 @@ struct jbg_dec_state {
unsigned long xmax, ymax; /* if possible abort before image gets *
* larger than this size */
int dmax; /* abort after this layer */
+ size_t maxmem; /* return JBG_ENOMEM if final image layer D
+ would require more than maxmem bytes */
};
diff --git a/libjbig/jbig.txt b/libjbig/jbig.txt
index 70ca464..4547b12 100644
--- a/libjbig/jbig.txt
+++ b/libjbig/jbig.txt
@@ -2,7 +2,7 @@
Using the JBIG-KIT library
--------------------------
-Markus Kuhn -- 2013-09-10
+Markus Kuhn -- 2020-08-03
This text explains how to use the functions provided by the JBIG-KIT
@@ -735,19 +735,36 @@ None of the above limitations can be exceeded by a JBIG data stream
that conforms to the ITU-T T.85 application profile for the use of
JBIG1 in fax machines.
-The current implementation of the jbig.c decoder does not impose any
-limits on the image size that it will process, as long as malloc() is
-able to allocate enough heap space for the resulting bitmaps. The only
-exception is that jbg_dec_in() will return "Input data stream uses
+The maximum image size that a BIE header (BIH) can indicate is X_D =
+2^32-1 pixels wide, Y_D = 2^32-1 lines high, with P = 255 bits per
+pixel. Such an image would, in uncompressed form, require about 588
+exabytes. Once jbg_dec_in() has received the 20-byte long BIH at the
+start of the BIE, it will call malloc() to allocate enough memory to
+hold the uncompressed image planes. Users may, therefore, want to
+defend their application against excessive image-size parameters in a
+received BIH, by checking X_D, Y_D, and P against appropriate safety
+limits before handing over the BIE header to jbg_dec_in(). BIE headers
+indicating too large images might be abused for denial of service
+attacks, to exhaust the memory of a system (e.g., CVE-2017-9937). To
+manage this risk, the jbig.c decoder will now, by default, return "Not
+enough memory available" (JBG_ENOMEM) if the resulting final image
+layer would occupy more than 2 gigabytes. Users can adjust this limit
+by changing sd->maxmem right after having called jbg_dec_init(&sd).
+The actual amount of memory allocated with malloc() calls during the
+decoding process is somewhat higher (at least 25%) than the limit set
+in sd->maxmem, as the decoder requires additional heap memory that
+depends on the image dimensions.
+
+The jbg_dec_in() function will return "Input data stream uses
unimplemented JBIG features" (JBG_EIMPL | 1) if Y_D equals 0xffffffff,
which is an extreme value commonly used to encode images according to
ITU-T T.85 where the height was unknown when the BIH was emitted.
-After jbg_dec_in() received the 20-byte long BIH at the start of the
-BIE, it will malloc() to allocate enough memory to hold the requested
-image planes and layers. If you want to defend your application
-against excessive image-size parameters in a received BIH, then do
-make sure that you check X_D, Y_D, and P against appropriate safety
-limits before handing over the BIH to jbg_dec_in().
+
+All malloc(), realloc() and free() functions called by jbig.c are
+wrapped by the functions checked_malloc(), checked_realloc() and
+checked_free(). These simply call abort() when memory allocation
+fails. Developpers of embedded systems may want to replace them with
+alternative forms of exception handling.
There are two more limitations of the current implementation of the
jbig.c decoder that might cause problems with processing JBIG data
--
2.45.0

View File

@ -0,0 +1,160 @@
diff -Naur jbigkit-2.1.old/libjbig/Makefile jbigkit-2.1/libjbig/Makefile
--- jbigkit-2.1.old/libjbig/Makefile 2014-03-27 19:47:15.000000000 +0100
+++ jbigkit-2.1/libjbig/Makefile 2014-08-04 10:45:31.865773710 +0200
@@ -4,25 +4,27 @@
CC = gcc
# Options for the compiler: A high optimization level is suggested
-CFLAGS = -g -O -W -Wall -ansi -pedantic # --coverage
+CFLAGS = $(EXTRA_CFLAGS) -W -Wall -ansi -pedantic # --coverage
+PICFLAGS := -fPIC -DPIC
-all: libjbig.a libjbig85.a tstcodec tstcodec85
+all: libjbig.so.$(VERSION) tstcodec tstcodec85
-tstcodec: tstcodec.o jbig.o jbig_ar.o
- $(CC) $(CFLAGS) -o tstcodec tstcodec.o jbig.o jbig_ar.o
+tstcodec: tstcodec.o libjbig.so
+ $(CC) $(CFLAGS) -o tstcodec $< -L. -ljbig
-tstcodec85: tstcodec85.o jbig85.o jbig_ar.o
- $(CC) $(CFLAGS) -o tstcodec85 tstcodec85.o jbig85.o jbig_ar.o
+tstcodec85: tstcodec85.o libjbig85.so
+ $(CC) $(CFLAGS) -o tstcodec85 $< -L. -ljbig85
-libjbig.a: jbig.o jbig_ar.o
- rm -f libjbig.a
- ar rc libjbig.a jbig.o jbig_ar.o
- -ranlib libjbig.a
+%.so: %.so.$(VERSION)
+ ln -sf $< $@
-libjbig85.a: jbig85.o jbig_ar.o
- rm -f libjbig85.a
- ar rc libjbig85.a jbig85.o jbig_ar.o
- -ranlib libjbig85.a
+libjbig.so.$(VERSION): jbig.o jbig_ar.o
+ $(CC) $(CFLAGS) -shared -Wl,-soname,$@ -o $@ $^
+
+libjbig85.so.$(VERSION): jbig85.o jbig_ar.o
+ $(CC) $(CFLAGS) -shared -Wl,-soname,$@ -o $@ $^
+
+jbig.o jbig85.o jbig_ar.o: CFLAGS += $(PICFLAGS)
jbig.o: jbig.c jbig.h jbig_ar.h
jbig85.o: jbig85.c jbig85.h jbig_ar.h
@@ -43,11 +45,11 @@
clang --analyze *.c
test: tstcodec tstcodec85
- ./tstcodec
- ./tstcodec85
+ LD_LIBRARY_PATH=`pwd` ./tstcodec
+ LD_LIBRARY_PATH=`pwd` ./tstcodec85
t82test.pbm: tstcodec
- ./tstcodec $@
+ LD_LIBRARY_PATH=`pwd` ./tstcodec $@
clean:
rm -f *.o *.gcda *.gcno *.gcov *.plist *~ core gmon.out dbg_d\=??.pbm
diff -Naur jbigkit-2.1.old/Makefile jbigkit-2.1/Makefile
--- jbigkit-2.1.old/Makefile 2014-03-27 19:47:15.000000000 +0100
+++ jbigkit-2.1/Makefile 2014-08-04 10:52:09.242027746 +0200
@@ -4,25 +4,26 @@
CC = gcc
# Options for the compiler: A high optimization level is suggested
-CFLAGS = -O2 -W -Wno-unused-result
+CFLAGS = $(EXTRA_CFLAGS) -W -Wno-unused-result
# CFLAGS = -O -g -W -Wall -Wno-unused-result -ansi -pedantic # -DDEBUG
export CC CFLAGS
VERSION=2.1
+export VERSION
all: lib pbm
@echo "Enter 'make test' in order to start some automatic tests."
lib:
- cd libjbig && $(MAKE) -e
+ make -C libjbig
pbm: lib
- cd pbmtools && $(MAKE) -e
+ make -C pbmtools
test: lib pbm
- cd libjbig && $(MAKE) test
- cd pbmtools && $(MAKE) test
+ LD_LIBRARY_PATH=`pwd`/libjbig make -C libjbig test
+ LD_LIBRARY_PATH=`pwd`/libjbig make -C pbmtools test
analyze:
cd libjbig && $(MAKE) analyze
@@ -30,8 +31,8 @@
clean:
rm -f *~ core
- cd libjbig && $(MAKE) clean
- cd pbmtools && $(MAKE) clean
+ make -C libjbig clean
+ make -C pbmtools clean
distribution:
rm -rf jbigkit-$(VERSION)
diff -Naur jbigkit-2.1.old/pbmtools/Makefile jbigkit-2.1/pbmtools/Makefile
--- jbigkit-2.1.old/pbmtools/Makefile 2014-03-27 19:47:15.000000000 +0100
+++ jbigkit-2.1/pbmtools/Makefile 2014-08-04 10:49:47.694581174 +0200
@@ -4,26 +4,26 @@
CC = gcc
# Options for the compiler
-CFLAGS = -g -O -W -Wall -Wno-unused-result -ansi -pedantic # --coverage
+CFLAGS = $(EXTRA_CFLAGS) -W -Wall -Wno-unused-result -ansi -pedantic # --coverage
CPPFLAGS = -I../libjbig
.SUFFIXES: .1 .5 .txt $(SUFFIXES)
.PHONY: txt test test82 test85 clean
-all: pbmtojbg jbgtopbm pbmtojbg85 jbgtopbm85 txt
+all: pbmtojbg jbgtopbm pbmtojbg85 jbgtopbm85 # txt
txt: pbmtojbg.txt jbgtopbm.txt pbm.txt pgm.txt
-pbmtojbg: pbmtojbg.o ../libjbig/libjbig.a
+pbmtojbg: pbmtojbg.o ../libjbig/libjbig.so
$(CC) $(CFLAGS) -o pbmtojbg pbmtojbg.o -L../libjbig -ljbig
-jbgtopbm: jbgtopbm.o ../libjbig/libjbig.a
+jbgtopbm: jbgtopbm.o ../libjbig/libjbig.so
$(CC) $(CFLAGS) -o jbgtopbm jbgtopbm.o -L../libjbig -ljbig
-pbmtojbg85: pbmtojbg85.o ../libjbig/libjbig85.a
+pbmtojbg85: pbmtojbg85.o ../libjbig/libjbig85.so
$(CC) $(CFLAGS) -o pbmtojbg85 pbmtojbg85.o -L../libjbig -ljbig85
-jbgtopbm85: jbgtopbm85.o ../libjbig/libjbig85.a
+jbgtopbm85: jbgtopbm85.o ../libjbig/libjbig85.so
$(CC) $(CFLAGS) -o jbgtopbm85 jbgtopbm85.o -L../libjbig -ljbig85
jbgtopbm.o: jbgtopbm.c ../libjbig/jbig.h
@@ -31,13 +31,13 @@
jbgtopbm85.o: jbgtopbm85.c ../libjbig/jbig85.h
pbmtojbg85.o: pbmtojbg85.c ../libjbig/jbig85.h
-../libjbig/libjbig.a: ../libjbig/jbig.c ../libjbig/jbig.h \
+../libjbig/libjbig.so: ../libjbig/jbig.c ../libjbig/jbig.h \
../libjbig/jbig_ar.c ../libjbig/jbig_ar.h
- make -C ../libjbig libjbig.a
+ make -C ../libjbig libjbig.so
-../libjbig/libjbig85.a: ../libjbig/jbig85.c ../libjbig/jbig85.h \
+../libjbig/libjbig85.so: ../libjbig/jbig85.c ../libjbig/jbig85.h \
../libjbig/jbig_ar.c ../libjbig/jbig_ar.h
- make -C ../libjbig libjbig85.a
+ make -C ../libjbig libjbig85.so
analyze:
clang $(CPPFLAGS) --analyze *.c

117
jbigkit.spec Normal file
View File

@ -0,0 +1,117 @@
Name: jbigkit
Version: 2.1
Release: 2mamba
Summary: Data compression library/utilities for bi-level high-resolution images
Group: System/Libraries
Vendor: openmamba
Distribution: openmamba
Packager: Silvan Calarco <silvan.calarco@mambasoft.it>
URL: https://www.cl.cam.ac.uk/~mgk25/jbigkit/
Source: https://www.cl.cam.ac.uk/~mgk25/jbigkit/download/jbigkit-%{version}.tar.gz
Patch0: jbigkit-2.1-shared_lib.patch
Patch1: jbigkit-2.1-ldflags.patch
Patch2: jbigkit-2.1-build_warnings.patch
Patch3: jbigkit-2.1-coverity.patch
Patch4: jbigkit-2.1-new-jbig.c-limit-s-maxmem-maximum-decoded-image-size.patch
Patch5: jbigkit-2.1-jbg_newlen-check-for-end-of-file-within-MARKER_NEWLE.patch
License: GPL
## AUTOBUILDREQ-BEGIN
BuildRequires: glibc-devel
## AUTOBUILDREQ-END
Requires: lib%{name} = %{?epoch:%epoch:}%{version}-%{release}
Provides: libjbig-tools
Obsoletes: libjbig-tools < 2.1-2mamba
%description
Data compression library/utilities for bi-level high-resolution images.
%package -n libjbig
Group: System/Libraries
Summary: Shared libraries for %{name}
%ifarch x86_64 aarch64
Provides: libjbig.so.0()(64bit)
Provides: libjbig.so.2.0()(64bit)
%else
Provides: libjbig.so.0
Provides: libjbig.so.2.0
%endif
%description -n libjbig
This package contains shared libraries for %{name}.
%package -n libjbig-devel
Group: Development/Libraries
Summary: Development files for %{name}
Requires: libjbig = %{?epoch:%epoch:}%{version}-%{release}
%description -n libjbig-devel
This package contains libraries and header files for developing applications that use %{name}.
%debug_package
%prep
%setup -q
%patch 0 -p1 -b .shared_lib
%patch 1 -p1 -b .ldflags
%patch 2 -p1 -b .build_warnings
%patch 3 -p1 -b .coverity
%patch 4 -p1 -b .new-jbig.c-limit-s-maxmem-maximum-decoded-image-size
%patch 5 -p1 -b .jbg_newlen-check-for-end-of-file-within-MARKER_NEWLE
%build
%make EXTRA_CFLAGS="%{optflags}"
%install
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
install -D -m0644 libjbig/*.h -t %{buildroot}%{_includedir}
install -D -m0755 libjbig/*.so.* -t %{buildroot}%{_libdir}
for lib in libjbig.so libjbig85.so; do
ln -sv "$lib.%{version}" %{buildroot}%{_libdir}/$lib
done
install -D -m0755 pbmtools/{jbgtopbm{,85},pbmtojbg{,85}} -t %{buildroot}%{_bindir}
install -D -m0644 pbmtools/*.1* -t %{buildroot}%{_mandir}/man1/
ln -s libjbig.so.2.1 %{buildroot}%{_libdir}/libjbig.so.0
ln -s libjbig.so.2.1 %{buildroot}%{_libdir}/libjbig.so.2.0
%clean
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%files
%defattr(-,root,root)
%{_bindir}/jbgtopbm
%{_bindir}/jbgtopbm85
%{_bindir}/pbmtojbg
%{_bindir}/pbmtojbg85
%{_mandir}/man1/jbgtopbm.1*
%{_mandir}/man1/pbmtojbg.1*
%files -n libjbig
%defattr(-,root,root)
%{_libdir}/libjbig.so.*
%{_libdir}/libjbig85.so.*
%doc COPYING
%files -n libjbig-devel
%defattr(-,root,root)
%{_includedir}/jbig.h
%{_includedir}/jbig85.h
%{_includedir}/jbig_ar.h
%{_libdir}/libjbig.so
%{_libdir}/libjbig85.so
%doc CHANGES TODO
%changelog
* Fri Nov 29 2024 Silvan Calarco <silvan.calarco@mambasoft.it> 2.1-2mamba
- rename from libjbig to jbigkit; apply well known patches
* Sun Feb 14 2021 Silvan Calarco <silvan.calarco@mambasoft.it> 2.1-1mamba
- update to 2.1
* Mon Dec 19 2011 Silvan Calarco <silvan.calarco@mambasoft.it> 2.0-2mamba
- added patch to build shared library
- install required header file jbig_ar.h
* Sun Jul 05 2009 Tiziana Ferro <tiziana.ferro@email.it> 2.0-1mamba
- package created by autospec