summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2014-08-20 06:41:24 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2014-08-20 06:41:24 +0000
commitcf5da7c470e3fd0585f1e1bc28dc5329d8240e01 (patch)
tree9d68927b9fc598d4350886c73146fc99ffd120d9 /Build
parentb42dedaeace1c302538059b949f97bc03dfcabd3 (diff)
texk/web2c/omegafonts: Avoid segfault with broken OFM files. Add a new test case
git-svn-id: svn://tug.org/texlive/trunk@34986 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/web2c/omegafonts/ChangeLog7
-rw-r--r--Build/source/texk/web2c/omegafonts/Makefile.am9
-rw-r--r--Build/source/texk/web2c/omegafonts/Makefile.in23
-rw-r--r--Build/source/texk/web2c/omegafonts/char_routines.c27
-rwxr-xr-xBuild/source/texk/web2c/omegafonts/check.test28
-rw-r--r--Build/source/texk/web2c/omegafonts/ligkern_routines.c23
-rw-r--r--Build/source/texk/web2c/omegafonts/tests/check.ofmbin0 -> 328 bytes
-rw-r--r--Build/source/texk/web2c/omegafonts/tests/check.opl66
-rw-r--r--Build/source/texk/web2c/omegafonts/tests/checked.opl61
9 files changed, 222 insertions, 22 deletions
diff --git a/Build/source/texk/web2c/omegafonts/ChangeLog b/Build/source/texk/web2c/omegafonts/ChangeLog
index 601ca2bfa84..43691a1880f 100644
--- a/Build/source/texk/web2c/omegafonts/ChangeLog
+++ b/Build/source/texk/web2c/omegafonts/ChangeLog
@@ -1,3 +1,10 @@
+2014-08-19 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * char_routines.c, ligkern_routines.c: More OFM checking.
+ * check.test, check.{ofm,opl}, checked.opl:
+ Shell script and data for a new test.
+ * Makefile.am: Add the new test.
+
2014-08-18 Peter Breitenlohner <peb@mppmu.mpg.de>
* ofonts.test: Fix parallel tests.
diff --git a/Build/source/texk/web2c/omegafonts/Makefile.am b/Build/source/texk/web2c/omegafonts/Makefile.am
index 806f0ff8948..91eaaea3df1 100644
--- a/Build/source/texk/web2c/omegafonts/Makefile.am
+++ b/Build/source/texk/web2c/omegafonts/Makefile.am
@@ -96,9 +96,9 @@ endif OTANGLE
## Tests
##
-OMFONTS_tests = charwd.test level1.test ligkern.test ofonts.test omfonts.test \
- overbmp.test realnum.test repeat.test selectfont.test shorten.test \
- specialhex.test yannis.test
+OMFONTS_tests = charwd.test check.test level1.test ligkern.test ofonts.test \
+ omfonts.test overbmp.test realnum.test repeat.test selectfont.test \
+ shorten.test specialhex.test yannis.test
if OTANGLE
TESTS = $(OMFONTS_tests)
endif OTANGLE
@@ -108,6 +108,9 @@ EXTRA_DIST = $(OMFONTS_tests)
## charwd.test
EXTRA_DIST += tests/charwd-r.pl tests/charwd-v.vpl
DISTCLEANFILES += tests/charwdr.* tests/charwdv.*
+## check.test
+EXTRA_DIST += tests/check.ofm tests/check.opl tests/checked.opl
+DISTCLEANFILES += tests/xcheck*
## level1.test
EXTRA_DIST += tests/level1.opl
DISTCLEANFILES += tests/xlevel1.*
diff --git a/Build/source/texk/web2c/omegafonts/Makefile.in b/Build/source/texk/web2c/omegafonts/Makefile.in
index 6b5e259ba12..d839d1a27ce 100644
--- a/Build/source/texk/web2c/omegafonts/Makefile.in
+++ b/Build/source/texk/web2c/omegafonts/Makefile.in
@@ -705,14 +705,14 @@ call_omfonts_CPPFLAGS = -DEXEPROG=\"omfonts.exe\"
nodist_call_omfonts_SOURCES = ../callexe.c
call_omfonts_LDADD =
DISTCLEANFILES = pl-parser.output tests/charwdr.* tests/charwdv.* \
- tests/xlevel1.* tests/xlig*.* tests/xofont* tests/Cherokee.tfm \
- tests/OCherokee.ofm tests/OCherokee.opl tests/OCherokee.ovf \
- tests/xCherokee.* tests/xOCherokee.* tests/xinbmp* \
- tests/xoverbmp* tests/realnum.* tests/xrepeated.* \
- tests/sample*.ofm tests/sample*.ovf tests/sample1-h.opl \
- tests/xsample*.out tests/shortend.* tests/specialhex.ofm \
- tests/specialhex.opl tests/specialhex.ovf tests/xspecialhex.* \
- tests/*yarabic*
+ tests/xcheck* tests/xlevel1.* tests/xlig*.* tests/xofont* \
+ tests/Cherokee.tfm tests/OCherokee.ofm tests/OCherokee.opl \
+ tests/OCherokee.ovf tests/xCherokee.* tests/xOCherokee.* \
+ tests/xinbmp* tests/xoverbmp* tests/realnum.* \
+ tests/xrepeated.* tests/sample*.ofm tests/sample*.ovf \
+ tests/sample1-h.opl tests/xsample*.out tests/shortend.* \
+ tests/specialhex.ofm tests/specialhex.opl tests/specialhex.ovf \
+ tests/xspecialhex.* tests/*yarabic*
linked_programs = ofm2opl opl2ofm ovf2ovp ovp2ovf
bin_links = \
omfonts$(EXEEXT):ofm2opl \
@@ -720,12 +720,13 @@ bin_links = \
omfonts$(EXEEXT):ovf2ovp \
omfonts$(EXEEXT):ovp2ovf
-OMFONTS_tests = charwd.test level1.test ligkern.test ofonts.test omfonts.test \
- overbmp.test realnum.test repeat.test selectfont.test shorten.test \
- specialhex.test yannis.test
+OMFONTS_tests = charwd.test check.test level1.test ligkern.test ofonts.test \
+ omfonts.test overbmp.test realnum.test repeat.test selectfont.test \
+ shorten.test specialhex.test yannis.test
@OTANGLE_TRUE@TESTS = $(OMFONTS_tests)
EXTRA_DIST = $(OMFONTS_tests) tests/charwd-r.pl tests/charwd-v.vpl \
+ tests/check.ofm tests/check.opl tests/checked.opl \
tests/level1.opl tests/ligall.opl tests/ligbch.opl \
tests/ligbdy.opl tests/ligblb.opl tests/ligblv.opl \
tests/ligblv.ovp tests/ligloop1.ofm tests/ligloop1.opl \
diff --git a/Build/source/texk/web2c/omegafonts/char_routines.c b/Build/source/texk/web2c/omegafonts/char_routines.c
index 7f3989b33ee..0601a72002e 100644
--- a/Build/source/texk/web2c/omegafonts/char_routines.c
+++ b/Build/source/texk/web2c/omegafonts/char_routines.c
@@ -370,6 +370,17 @@ print_characters(boolean read_ovf)
print_character_repeat(c, copies);
else
print_character(c);
+#define check_range(ndx, mx, name) \
+ if (entry->index_indices[ndx] >= mx) { \
+ fprintf(stderr, "\n%s index for character \"%x is too large;\n" \
+ "so I reset it to zero.\n", name, c); \
+ entry->index_indices[ndx] = 0; \
+ changed = TRUE; \
+ }
+ check_range(C_WD, nw, "Width")
+ check_range(C_HT, nh, "Height")
+ check_range(C_DP, nd, "Depth")
+ check_range(C_IC, ni, "Italic correction")
for (k=C_MIN; k<C_MAX; k++) {
if (entry->index_indices[k] != 0) {
print_character_measure(k,
@@ -380,6 +391,14 @@ print_characters(boolean read_ovf)
switch (entry->tag) {
case TAG_NONE: { break; }
case TAG_LIG: {
+ if (entry->remainder >= nl) {
+ fprintf(stderr, "\nLigature/kern starting index for character \"%x is too large;\n"
+ "so I removed it.\n", c);
+ entry->tag = 0;
+ entry->remainder = 0;
+ changed = TRUE;
+ break;
+ }
left();
out("COMMENT"); out_ln();
lentry = lig_kern_table + entry->remainder;
@@ -403,6 +422,14 @@ print_characters(boolean read_ovf)
break;
}
case TAG_EXT: {
+ if (entry->remainder >= ne) {
+ fprintf(stderr, "\nExtensible index for character \"%x is too large;\n"
+ "so I reset it to zero.\n", c);
+ entry->tag = 0;
+ entry->remainder = 0;
+ changed = TRUE;
+ break;
+ }
print_var_character();
exten = exten_table[entry->remainder];
for (j=E_MIN; j<=E_MAX; j++) {
diff --git a/Build/source/texk/web2c/omegafonts/check.test b/Build/source/texk/web2c/omegafonts/check.test
new file mode 100755
index 00000000000..288cb9411ef
--- /dev/null
+++ b/Build/source/texk/web2c/omegafonts/check.test
@@ -0,0 +1,28 @@
+#! /bin/sh
+
+# Copyright (C) 2014 Peter Breitenlohner <tex-live@tug.org>
+# You may freely use, modify and/or distribute this file.
+
+tests=tests
+
+test -d tests || mkdir -p tests
+
+TEXMFCNF=$srcdir/../../kpathsea
+OFMFONTS=".;./tests"
+export TEXMFCNF OFMFONTS
+
+echo && echo "*** ofm2opl check xcheck"
+./omfonts -ofm2opl $srcdir/tests/check tests/xcheck || exit 1
+
+echo && echo "*** diff check.opl xcheck.opl"
+diff $srcdir/tests/check.opl tests/xcheck.opl || exit 1
+
+echo && echo "*** opl2ofm xcheck xchecked"
+./omfonts -opl2ofm tests/xcheck tests/xchecked || exit 1
+
+echo && echo "*** ofm2opl xchecked xchecked"
+./omfonts -ofm2opl tests/xchecked tests/xchecked || exit 1
+
+echo && echo "*** diff checked.opl xchecked.opl"
+diff $srcdir/tests/checked.opl tests/xchecked.opl || exit 1
+
diff --git a/Build/source/texk/web2c/omegafonts/ligkern_routines.c b/Build/source/texk/web2c/omegafonts/ligkern_routines.c
index 3a5d590613f..09488eb3655 100644
--- a/Build/source/texk/web2c/omegafonts/ligkern_routines.c
+++ b/Build/source/texk/web2c/omegafonts/ligkern_routines.c
@@ -27,6 +27,7 @@ along with Omega; if not, write to the Free Software Foundation, Inc.,
#include "ligkern_routines.h"
#include "char_routines.h"
#include "out_routines.h"
+#include "parse_ofm.h"
#include "print_routines.h"
#include "error_routines.h"
#include "header_routines.h"
@@ -246,9 +247,10 @@ print_ligkern_table(void)
else if ((activity[i] == A_ACCESSIBLE) && (r < STOP_FLAG)) {
r += i + 1;
if (r >= nl) {
- fprintf(stderr, "Ligature/kern step %u skips too far; "
- "I made it stop.\nl", i);
+ fprintf(stderr, "Bad OFM file: Ligature/kern step %u skips too far;\n"
+ "I made it stop.\n", i);
lig_kern_table[i].entries[0] = STOP_FLAG;
+ changed = TRUE;
} else
activity[r] = A_ACCESSIBLE;
}
@@ -280,13 +282,17 @@ void
print_one_lig_kern_entry(four_entries *lentry, boolean show_stop)
{
if (lentry->entries[2] >= KERN_FLAG) {
- if (ofm_level==OFM_TFM) {
- print_kerning_command(lentry->entries[1],
- kern_table[256*(lentry->entries[2]-KERN_FLAG)+lentry->entries[3]]);
- } else {
- print_kerning_command(lentry->entries[1],
- kern_table[65536*(lentry->entries[2]-KERN_FLAG)+lentry->entries[3]]);
+ unsigned r = (ofm_level==OFM_TFM ? 256 : 65536)*(lentry->entries[2]-KERN_FLAG)+lentry->entries[3];
+ fix v;
+ if (r < nk)
+ v = kern_table[r];
+ else {
+ if (show_stop == TRUE)
+ fprintf(stderr, "Bad OFM file: Kern index too large.\n");
+ v = 0;
+ changed = TRUE;
}
+ print_kerning_command(lentry->entries[1], v);
} else {
print_ligature_command(lentry->entries[2],
lentry->entries[1],
@@ -656,6 +662,7 @@ retrieve_ligkern_table(unsigned char *ofm_lig_table,
if (r >= nl) {
fprintf(stderr, "Ligature/kern starting index for boundarychar is too large;\n"
"so I removed it.\n");
+ changed = TRUE;
} else {
bchar_label = r;
activity[r] = A_ACCESSIBLE;
diff --git a/Build/source/texk/web2c/omegafonts/tests/check.ofm b/Build/source/texk/web2c/omegafonts/tests/check.ofm
new file mode 100644
index 00000000000..9ae88c5aa40
--- /dev/null
+++ b/Build/source/texk/web2c/omegafonts/tests/check.ofm
Binary files differ
diff --git a/Build/source/texk/web2c/omegafonts/tests/check.opl b/Build/source/texk/web2c/omegafonts/tests/check.opl
new file mode 100644
index 00000000000..0dd75590250
--- /dev/null
+++ b/Build/source/texk/web2c/omegafonts/tests/check.opl
@@ -0,0 +1,66 @@
+(OFMLEVEL H 0)
+(FONTDIR TL)
+(FAMILY UNSPECIFIED)
+(FACE F MRR)
+(CODINGSCHEME CHECKING TEST: NOT A REAL FONT)
+(DESIGNSIZE R 10.0)
+(COMMENT DESIGNSIZE IS IN POINTS)
+(COMMENT OTHER SIZES ARE MULTIPLES OF DESIGNSIZE)
+(CHECKSUM H 1A78D100)
+(SEVENBITSAFEFLAG FALSE)
+(LIGTABLE
+ (LABEL H 41)
+ (LIG H 41 H 44)
+ (LIG/ H 42 H 44)
+ (/LIG H 43 H 44)
+ (STOP)
+ (LABEL H 42)
+ (/LIG/ H 41 H 44)
+ (LIG/> H 42 H 44)
+ (/LIG> H 43 H 44)
+ (STOP)
+ (LABEL H 43)
+ (/LIG/> H 41 H 44)
+ (/LIG/>> H 42 H 44)
+ (KRN H 43 R 0.125)
+ (STOP)
+ (COMMENT THIS PART OF THE PROGRAM IS NEVER USED!
+ (KRN H 41 R 0.25)
+ (KRN H 42 R 0.0)
+ (KRN H 43 R 0.5)
+ )
+ )
+(CHARACTER H 41
+ (COMMENT
+ (LIG H 41 H 44)
+ (LIG/ H 42 H 44)
+ (/LIG H 43 H 44)
+ )
+ )
+(CHARACTER H 42
+ (CHARWD R 0.125)
+ (COMMENT
+ (/LIG/ H 41 H 44)
+ (LIG/> H 42 H 44)
+ (/LIG> H 43 H 44)
+ )
+ )
+(CHARACTER H 43
+ (CHARWD R 0.25)
+ (COMMENT
+ (/LIG/> H 41 H 44)
+ (/LIG/>> H 42 H 44)
+ (KRN H 43 R 0.125)
+ )
+ )
+(CHARACTER H 44
+ (CHARWD R 0.5)
+ )
+(CHARACTER H 45
+ (CHARWD R 0.5)
+ (NEXTLARGER H 46)
+ )
+(CHARACTER H 46
+ (CHARWD R 0.5)
+ )
+(COMMENT THE OFM FILE WAS BAD, SO THE DATA HAS BEEN CHANGED!)
diff --git a/Build/source/texk/web2c/omegafonts/tests/checked.opl b/Build/source/texk/web2c/omegafonts/tests/checked.opl
new file mode 100644
index 00000000000..cbb1c698f85
--- /dev/null
+++ b/Build/source/texk/web2c/omegafonts/tests/checked.opl
@@ -0,0 +1,61 @@
+(OFMLEVEL H 0)
+(FONTDIR TL)
+(FAMILY UNSPECIFIED)
+(FACE F MRR)
+(CODINGSCHEME CHECKING TEST: NOT A REAL FONT)
+(DESIGNSIZE R 10.0)
+(COMMENT DESIGNSIZE IS IN POINTS)
+(COMMENT OTHER SIZES ARE MULTIPLES OF DESIGNSIZE)
+(CHECKSUM H 1A78D100)
+(SEVENBITSAFEFLAG FALSE)
+(LIGTABLE
+ (LABEL H 41)
+ (LIG H 41 H 44)
+ (LIG/ H 42 H 44)
+ (/LIG H 43 H 44)
+ (STOP)
+ (LABEL H 42)
+ (/LIG/ H 41 H 44)
+ (LIG/> H 42 H 44)
+ (/LIG> H 43 H 44)
+ (STOP)
+ (LABEL H 43)
+ (/LIG/> H 41 H 44)
+ (/LIG/>> H 42 H 44)
+ (KRN H 43 R 0.125)
+ (STOP)
+ )
+(CHARACTER H 41
+ (CHARWD R 0.0)
+ (COMMENT
+ (LIG H 41 H 44)
+ (LIG/ H 42 H 44)
+ (/LIG H 43 H 44)
+ )
+ )
+(CHARACTER H 42
+ (CHARWD R 0.125)
+ (COMMENT
+ (/LIG/ H 41 H 44)
+ (LIG/> H 42 H 44)
+ (/LIG> H 43 H 44)
+ )
+ )
+(CHARACTER H 43
+ (CHARWD R 0.25)
+ (COMMENT
+ (/LIG/> H 41 H 44)
+ (/LIG/>> H 42 H 44)
+ (KRN H 43 R 0.125)
+ )
+ )
+(CHARACTER H 44
+ (CHARWD R 0.5)
+ )
+(CHARACTER H 45
+ (CHARWD R 0.5)
+ (NEXTLARGER H 46)
+ )
+(CHARACTER H 46
+ (CHARWD R 0.5)
+ )