texlive[43950] Build/source/texk/web2c/pdftexdir: more erroneous map
commits+karl at tug.org
commits+karl at tug.org
Fri Apr 21 01:09:42 CEST 2017
Revision: 43950
http://tug.org/svn/texlive?view=revision&revision=43950
Author: karl
Date: 2017-04-21 01:09:41 +0200 (Fri, 21 Apr 2017)
Log Message:
-----------
more erroneous map entry checks
Modified Paths:
--------------
trunk/Build/source/texk/web2c/pdftexdir/ChangeLog
trunk/Build/source/texk/web2c/pdftexdir/mapfile.c
Modified: trunk/Build/source/texk/web2c/pdftexdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/ChangeLog 2017-04-20 21:16:48 UTC (rev 43949)
+++ trunk/Build/source/texk/web2c/pdftexdir/ChangeLog 2017-04-20 23:09:41 UTC (rev 43950)
@@ -1,3 +1,13 @@
+2017-04-19 Karl Berry <karl at freefriends.org>
+
+ * mapfile.c (read_field): new parameter buf_size,
+ and check buffer for overflow, as in append_char_to_buf.
+ (fm_scan_line): change read_field calls;
+ set tfm_name to empty string instead of leaving NULL.
+ (check_fm_entry): remove checks of tfm_name on every print;
+ check for empty tfm_name rather than lack of ps_name and font file;
+ check for non-empty tfm_name on slant/extend warnings.
+
2017-04-12 Karl Berry <karl at freefriends.org>
* mapfile.c (check_fm_entry): do not try to print fm->tfm_name,
Modified: trunk/Build/source/texk/web2c/pdftexdir/mapfile.c
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/mapfile.c 2017-04-20 21:16:48 UTC (rev 43949)
+++ trunk/Build/source/texk/web2c/pdftexdir/mapfile.c 2017-04-20 23:09:41 UTC (rev 43950)
@@ -46,10 +46,12 @@
static const char nontfm[] = "<nontfm>";
-#define read_field(r, q, buf) do { \
+#define read_field(r, q, buf, buf_size) do { \
q = buf; \
- while (*r != ' ' && *r != '<' && *r != '"' && *r != '\0') \
+ while (*r != ' ' && *r != '<' && *r != '"' && *r != '\0') { \
+ check_buf(q - (buf) + 1, (buf_size)); \
*q++ = *r++; \
+ } \
*q = '\0'; \
skip (r, ' '); \
} while (0)
@@ -271,13 +273,16 @@
return p;
}
+
/**********************************************************************/
-/* consistency check for map entry, with warn flag */
+/* consistency check for map entry, with warn flag; return zero if ok,
+ nonzero bits of warnings otherwise. */
static int check_fm_entry(fm_entry * fm, boolean warn)
{
int a = 0;
assert(fm != NULL);
+ assert(fm->tfm_name);
if (is_fontfile(fm) && !is_included(fm)) {
if (warn)
@@ -288,12 +293,10 @@
/* do not set variable |a| as this entry will still be accepted */
}
- /* if both ps_name and font file are missing, drop this entry */
- if (fm->ps_name == NULL && !is_fontfile(fm)) {
+ /* if no tfm name, nothing to do here; a bare tfm is ok */
+ if (*(fm->tfm_name) == '\0') {
if (warn)
- pdftex_warn
- ("invalid entry for `%s': both ps_name and font file missing",
- fm->tfm_name ? fm->tfm_name : "");
+ pdftex_warn ("invalid map entry: tfm missing");
a += 1;
}
@@ -301,18 +304,19 @@
if (is_truetype(fm) && is_reencoded(fm) && !is_subsetted(fm)) {
if (warn)
pdftex_warn
- ("invalid entry for `%s': only subsetted TrueType font can be reencoded",
- fm->tfm_name ? fm->tfm_name : "");
+ ("invalid entry for `%s': only subsetted TrueType fonts can be reencoded",
+ fm->tfm_name);
a += 2;
}
/* SlantFont and ExtendFont can be used only with Type1 fonts */
if ((fm->slant != 0 || fm->extend != 0)
- && !(is_t1fontfile(fm) && is_included(fm))) {
+ && (strlen(fm->tfm_name) == 0
+ || !(is_t1fontfile(fm) && is_included(fm)))) {
if (warn)
pdftex_warn
("invalid entry for `%s': SlantFont/ExtendFont can be used only with embedded Type1 fonts",
- fm->tfm_name ? fm->tfm_name : "");
+ fm->tfm_name);
a += 4;
}
@@ -320,17 +324,15 @@
if (abs(fm->slant) > 1000) {
if (warn)
pdftex_warn
- ("invalid entry for `%s': too big value of SlantFont (%g)",
- fm->tfm_name ? fm->tfm_name : "",
- fm->slant / 1000.0);
+ ("invalid entry for `%s': SlantFont value too big: %g",
+ fm->tfm_name, fm->slant / 1000.0);
a += 8;
}
if (abs(fm->extend) > 2000) {
if (warn)
pdftex_warn
- ("invalid entry for `%s': too big value of ExtendFont (%g)",
- fm->tfm_name ? fm->tfm_name : "",
- fm->extend / 1000.0);
+ ("invalid entry for `%s': ExtendFont value too big: %g",
+ fm->tfm_name, fm->extend / 1000.0);
a += 16;
}
@@ -340,7 +342,7 @@
if (warn)
pdftex_warn
("invalid entry for `%s': PidEid can be used only with subsetted non-reencoded TrueType fonts",
- fm->tfm_name ? fm->tfm_name : "");
+ fm->tfm_name);
a += 32;
}
@@ -428,10 +430,12 @@
if (*r == '\0' || is_cfg_comment(*r))
return;
fm = new_fm_entry();
- read_field(r, q, buf);
+ read_field(r, q, buf, FM_BUF_SIZE);
set_field(tfm_name);
+ if (fm->tfm_name == NULL) /* used in messages, so don't let be null */
+ fm->tfm_name = xstrdup ("");
if (!isdigit((unsigned char)*r)) { /* 2nd field ps_name may not start with a digit */
- read_field(r, q, buf);
+ read_field(r, q, buf, FM_BUF_SIZE);
set_field(ps_name);
}
if (isdigit((unsigned char)*r)) { /* font descriptor /Flags given? */
@@ -502,7 +506,7 @@
if (*r == '<' || *r == '[')
b = *r++;
}
- read_field(r, q, buf);
+ read_field(r, q, buf, FM_BUF_SIZE);
/* encoding, formats: '8r.enc' or '<8r.enc' or '<[8r.enc' */
if (strlen(buf) > 4 && strcasecmp(strend(buf) - 4, ".enc") == 0) {
fm->encname = add_encname(buf);
@@ -542,9 +546,7 @@
} else
set_type1(fm); /* assume a builtin font is Type1 */
- /* If the input is devious, check_fm_entry may not recognize a
- problem. Check that we have a tfm_name in any case. */
- if (check_fm_entry(fm, true) != 0 || ! fm->tfm_name)
+ if (check_fm_entry(fm, true) != 0)
goto bad_line;
/*
If we get here, the map line has been completely scanned without errors;
More information about the tex-live-commits
mailing list