Skip to content

Commit 56ddb24

Browse files
author
Ethan Bishop
committed
Patch memory corruption bug in fontforge
This causes some PDFs with certain fonts to explode pdf2htmlEX, due to a incorrect malloc argument
1 parent a9f2129 commit 56ddb24

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.2.1
4+
5+
* Patch memory corruption bug in `fontforge` triggered by some fonts.
6+
37
## 0.2.0
48

59
* Update to .net 8.

src/Pdf2Html/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM ubuntu:noble AS build-pdf2htmlex
33

44
# Produces a patched pdf2htmlEX using libopenjp 2.7 instead of libjpeg to get JPEG2000 support.
55

6-
ENV PDF2HTMLEX_BRANCH=cfl1
6+
ENV PDF2HTMLEX_BRANCH=cfl2
77
ENV UNATTENDED="--assume-yes"
88
ENV MAKE_PARALLEL="-j 4"
99
ENV PDF2HTMLEX_PREFIX=/usr/local
@@ -32,6 +32,7 @@ RUN patch ./poppler/glib/poppler-enums.c.template ./patches/poppler-enums.c.temp
3232
RUN patch ./poppler/glib/poppler-private.h ./patches/poppler-private.h.patch
3333
RUN ./buildScripts/buildPoppler
3434
RUN ./buildScripts/getFontforge
35+
RUN patch ./fontforge/fontforge/tottfgpos.c ./patches/fontforge-tottfgpos.c.patch
3536
RUN ./buildScripts/buildFontforge
3637
RUN ./buildScripts/buildPdf2htmlEX
3738
RUN ./buildScripts/installPdf2htmlEX
@@ -49,7 +50,7 @@ RUN apt update && apt install -y wget
4950
RUN wget http://archive.ubuntu.com/ubuntu/pool/main/libj/libjpeg-turbo/libjpeg-turbo8_2.0.3-0ubuntu1_amd64.deb
5051
RUN apt install -y ./libjpeg-turbo8_2.0.3-0ubuntu1_amd64.deb
5152
COPY --from=build-pdf2htmlex /source/pdf2htmlEX/imageBuild/*.deb /pdf2htmlEX/
52-
RUN apt install -y libjpeg62 libopenjp2-7 /pdf2htmlEX/pdf2htmlEX-0.18.8.rc1-cfl1-*-x86_64.deb
53+
RUN apt install -y libjpeg62 libopenjp2-7 /pdf2htmlEX/pdf2htmlEX-0.18.8.rc1-cfl2-*-x86_64.deb
5354

5455
WORKDIR /app
5556
COPY --from=build /app ./
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@@ -2091,10 +2091,10 @@
2+
}
3+
4+
static uint16 *FigureInitialClasses(FPST *fpst) {
5+
- uint16 *initial = malloc((fpst->nccnt+1)*sizeof(uint16));
6+
+ uint16 *initial = malloc((fpst->rule_cnt+1)*sizeof(uint16));
7+
int i, cnt, j;
8+
9+
- initial[fpst->nccnt] = 0xffff;
10+
+ initial[fpst->rule_cnt] = 0xffff;
11+
for ( i=cnt=0; i<fpst->rule_cnt; ++i ) {
12+
for ( j=0; j<cnt ; ++j )
13+
if ( initial[j] == fpst->rules[i].u.class.nclasses[0] )

0 commit comments

Comments
 (0)