more complete fix for pdftex match segfault fix from upstream
Norbert Preining
7 years ago
0 | fix problems with dvipdfmx eating characters | |
1 | patch by AKira Kakuto and Hironori Kitagawa | |
2 | see devel@texjp.org ML, thread starting at post nr 326 | |
3 | --- | |
4 | texk/dvipdfm-x/cidtype2.c | 10 +++++++--- | |
5 | 1 file changed, 7 insertions(+), 3 deletions(-) | |
6 | ||
7 | --- texlive-bin.orig/texk/dvipdfm-x/cidtype2.c | |
8 | +++ texlive-bin/texk/dvipdfm-x/cidtype2.c | |
9 | @@ -653,10 +653,14 @@ | |
10 | c = h_used_chars[i]; | |
11 | break; | |
12 | } | |
13 | + } | |
14 | + for (i = 8191; i >= 0; i--) { | |
15 | if (v_used_chars && v_used_chars[i] != 0) { | |
16 | - last_cid = i * 8 + 7; | |
17 | - c = v_used_chars[i]; | |
18 | - break; | |
19 | + if (i*8+7 >= last_cid) { | |
20 | + c = (i*8+7 > last_cid) ? (v_used_chars[i]) : (c | v_used_chars[i]); | |
21 | + last_cid = i * 8 + 7; | |
22 | + break; | |
23 | + } | |
24 | } | |
25 | } | |
26 | if (last_cid > 0) { |
0 | fix a segfault in pdftex | |
1 | reported by David Carlisle on tex-live | |
2 | http://tug.org/pipermail/tex-live/2016-June/038664.html | |
3 | proposed fix by Akira Kakuto | |
4 | http://tug.org/pipermail/tex-live/2016-June/038666.html | |
5 | originally on tex.sx | |
6 | http://chat.stackexchange.com/transcript/message/30145736 | |
7 | --- | |
8 | texk/web2c/pdftexdir/utils.c | 3 ++- | |
9 | 1 file changed, 2 insertions(+), 1 deletion(-) | |
10 | ||
11 | --- texlive-bin.orig/texk/web2c/pdftexdir/utils.c | |
12 | +++ texlive-bin/texk/web2c/pdftexdir/utils.c | |
13 | @@ -870,7 +870,8 @@ | |
14 | int size, len = 0; /* to avoid warning about uninitialized use of len */ | |
15 | ||
16 | boolean found = i < sub_match_count | |
17 | - && match_string != NULL && pmatch[i].rm_so >= 0 && i >= 0; | |
18 | + && match_string != NULL && pmatch[i].rm_so >= 0 && i >= 0 | |
19 | + && pmatch[i].rm_eo >= pmatch[i].rm_so; | |
20 | ||
21 | if (found) { | |
22 | len = pmatch[i].rm_eo - pmatch[i].rm_so; |
0 | --- | |
1 | texk/web2c/lib/ChangeLog | 2 +- | |
2 | texk/web2c/lib/texmfmp.c | 4 ++-- | |
3 | texk/web2c/man/pdftex.man | 2 +- | |
4 | texk/web2c/pdftexdir/NEWS | 2 +- | |
5 | 4 files changed, 5 insertions(+), 5 deletions(-) | |
6 | ||
7 | --- texlive-bin.orig/texk/web2c/lib/ChangeLog | |
8 | +++ texlive-bin/texk/web2c/lib/ChangeLog | |
9 | @@ -16,7 +16,7 @@ | |
10 | ||
11 | * texmfmp.c (init_start_time): new fn, factored out from | |
12 | initstarttime. | |
13 | - (get_date_and_time): if envvar SOURCE_DATE_EPOCH_TEX_PRIMITIVES | |
14 | + (get_date_and_time): if envvar FORCE_SOURCE_DATE | |
15 | is set, initialize minutes, day, month, year, from | |
16 | SOURCE_DATE_EPOCH value. Requested by Debian, thread starting at | |
17 | http://tug.org/pipermail/tex-k/2016-May/002691.html. | |
18 | --- texlive-bin.orig/texk/web2c/lib/texmfmp.c | |
19 | +++ texlive-bin/texk/web2c/lib/texmfmp.c | |
20 | @@ -2247,7 +2247,7 @@ | |
21 | { | |
22 | struct tm *tmptr; | |
23 | #ifndef onlyTeX | |
24 | - string sde_texprim = getenv ("SOURCE_DATE_EPOCH_TEX_PRIMITIVES"); | |
25 | + string sde_texprim = getenv ("FORCE_SOURCE_DATE"); | |
26 | if (sde_texprim && STREQ (sde_texprim, "1")) { | |
27 | init_start_time (); | |
28 | tmptr = gmtime (&start_time); | |
29 | @@ -2263,7 +2263,7 @@ | |
30 | /* warn if they gave an invalid value, empty (null string) ok. */ | |
31 | if (sde_texprim && strlen (sde_texprim) > 0 | |
32 | && !STREQ (sde_texprim, "0")) { | |
33 | -WARNING1 ("invalid value (expected 0 or 1) for environment variable $SOURCE_DATE_EPOCH_TEX_PRIMITIVES: %s", | |
34 | +WARNING1 ("invalid value (expected 0 or 1) for environment variable $FORCE_SOURCE_DATE: %s", | |
35 | sde_texprim); | |
36 | } | |
37 | #endif /* not onlyTeX */ | |
38 | --- texlive-bin.orig/texk/web2c/man/pdftex.man | |
39 | +++ texlive-bin/texk/web2c/man/pdftex.man | |
40 | @@ -379,7 +379,7 @@ | |
41 | timestamps in the PDF output, such as the CreationDate and ModDate keys. | |
42 | This is useful for making reproducible builds. | |
43 | .TP | |
44 | -.B SOURCE_DATE_EPOCH_TEX_PRIMITIVES | |
45 | +.B FORCE_SOURCE_DATE | |
46 | If set to the value "1", the time-related \*(TX primitives | |
47 | .RI ( \eyear , | |
48 | .IR \emonth , | |
49 | --- texlive-bin.orig/texk/web2c/pdftexdir/NEWS | |
50 | +++ texlive-bin/texk/web2c/pdftexdir/NEWS | |
51 | @@ -5,7 +5,7 @@ | |
52 | This by itself should suffice to create reproducible PDFs. The | |
53 | new primitives below support more granular output tweaks with the | |
54 | same intent. | |
55 | - - if the environment variable SOURCE_DATE_EPOCH_TEX_PRIMITIVES is set | |
56 | + - if the environment variable FORCE_SOURCE_DATE is set | |
57 | to 1, the \year, \day, and \time primitives are also initialized | |
58 | from the SOURCE_DATE_EPOCH value, instead of the current time. | |
59 |
14 | 14 | fix-mktexlsr-bashims |
15 | 15 | upupstream-xdvi-desktop-file |
16 | 16 | SDE-support-for-luatex |
17 | #dvipdfmx-cidtype2-fixes | |
18 | #pdftex-compare-fix-crash | |
19 | #sde_rename_tex_primitive | |
20 | 17 | upstream-svn41417-rename-sdetp |
18 | upstream-svn41418-pdftex-match-fix |
0 | fix pdftex match segfaults | |
1 | --- | |
2 | texk/web2c/pdftexdir/ChangeLog | 14 ++++++++++++++ | |
3 | texk/web2c/pdftexdir/NEWS | 5 ++++- | |
4 | texk/web2c/pdftexdir/utils.c | 30 +++++++++++++++++++++++------- | |
5 | 3 files changed, 41 insertions(+), 8 deletions(-) | |
6 | ||
7 | --- texlive-bin.orig/texk/web2c/pdftexdir/ChangeLog | |
8 | +++ texlive-bin/texk/web2c/pdftexdir/ChangeLog | |
9 | @@ -1,3 +1,17 @@ | |
10 | +2016-06-12 Karl Berry <karl@freefriends.org> | |
11 | + and Akira Kakuto <kakuto@fuk.kindai.ac.jp> | |
12 | + | |
13 | + * utils.c (last_match_succeeded): new static boolean. | |
14 | + (matchstrings): set it. | |
15 | + (getmatch): use it, plus check for non-NULL match_string sooner, | |
16 | + plus check that rm_eo >= rm_so. | |
17 | + Original bug report from David Carlisle, | |
18 | + http://tug.org/pipermail/tex-live/2016-June/038664.html | |
19 | + | |
20 | +2016-05-20 Karl Berry <karl@tug.org> | |
21 | + | |
22 | + * TeX Live 2016 release. | |
23 | + | |
24 | 2016-04-06 Karl Berry <karl@tug.org> | |
25 | ||
26 | * pdftexextra.h (COPYRIGHT_HOLDER): don't specifically mention peb | |
27 | --- texlive-bin.orig/texk/web2c/pdftexdir/NEWS | |
28 | +++ texlive-bin/texk/web2c/pdftexdir/NEWS | |
29 | @@ -1,8 +1,11 @@ | |
30 | - changes: | |
31 | - rename envvar SOURCE_DATE_EPOCH_TEX_PRIMITIVES to FORCE_SOURCE_DATE; | |
32 | no changes in functionality. | |
33 | + | |
34 | +- bugfixes: | |
35 | + - \pdflastmatch more reliable when there was no match | |
36 | --------------------------------------------------- | |
37 | -pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016) | |
38 | +pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016) (May 20, 2016) | |
39 | - changes: | |
40 | - if the environment variable SOURCE_DATE_EPOCH is set, use its value for | |
41 | the PDF CreationDate and ModDate values, and to seed the trailer /ID. | |
42 | --- texlive-bin.orig/texk/web2c/pdftexdir/utils.c | |
43 | +++ texlive-bin/texk/web2c/pdftexdir/utils.c | |
44 | @@ -817,12 +817,16 @@ | |
45 | pdf_printf("/ModDate (%s)\n", start_time_str); | |
46 | } | |
47 | ||
48 | + | |
49 | #define DEFAULT_SUB_MATCH_COUNT 10 | |
50 | static int sub_match_count = DEFAULT_SUB_MATCH_COUNT; | |
51 | static regmatch_t *pmatch = NULL; | |
52 | static char *match_string = NULL; | |
53 | +static int last_match_succeeded = 0; | |
54 | ||
55 | -void matchstrings(strnumber s, strnumber t, int subcount, boolean icase) | |
56 | +/* Implements \pdfmatch */ | |
57 | +void | |
58 | +matchstrings(strnumber s, strnumber t, int subcount, boolean icase) | |
59 | { | |
60 | regex_t preg; | |
61 | int cflags = REG_EXTENDED; | |
62 | @@ -857,20 +861,31 @@ | |
63 | pmatch = xtalloc(sub_match_count, regmatch_t); | |
64 | } | |
65 | ret = regexec(&preg, str, sub_match_count, pmatch, eflags); | |
66 | + | |
67 | xfree(match_string); | |
68 | - match_string = xstrdup(str); | |
69 | - strpool[poolptr++] = ((ret == 0) ? '1' : '0'); | |
70 | + match_string = xstrdup(str); /* save searched-in string, used below */ | |
71 | + last_match_succeeded = ret == 0; /* save whether match succeeded */ | |
72 | + strpool[poolptr++] = ((ret == 0) ? '1' : '0'); /* in string pool too */ | |
73 | } | |
74 | ||
75 | regfree(&preg); | |
76 | } | |
77 | ||
78 | -void getmatch(int i) | |
79 | +/* Implements \pdflastmatch */ | |
80 | + | |
81 | +void | |
82 | +getmatch(int i) | |
83 | { | |
84 | - int size, len = 0; /* to avoid warning about uninitialized use of len */ | |
85 | + int size; | |
86 | + int len = 0; /* avoid spurious uninitialized warning */ | |
87 | ||
88 | - boolean found = i < sub_match_count | |
89 | - && match_string != NULL && pmatch[i].rm_so >= 0 && i >= 0; | |
90 | + boolean found | |
91 | + = i >= 0 /* should always be so due to pdftex.web */ | |
92 | + && i < sub_match_count /* if >subcount, not found by definition */ | |
93 | + && match_string != NULL /* first call, and just in case */ | |
94 | + && last_match_succeeded /* if no match, not found */ | |
95 | + && pmatch[i].rm_so >= 0 /* if no starting position, not found */ | |
96 | + && pmatch[i].rm_eo >= pmatch[i].rm_so; /* just in case */ | |
97 | ||
98 | if (found) { | |
99 | len = pmatch[i].rm_eo - pmatch[i].rm_so; | |
100 | @@ -903,6 +918,7 @@ | |
101 | strpool[poolptr++] = '>'; | |
102 | } | |
103 | ||
104 | + | |
105 | /* function strips trailing zeros in string with numbers; */ | |
106 | /* leading zeros are not stripped (as in real life) */ | |
107 | char *stripzeros(char *a) |