diff options
Diffstat (limited to 'Build/source')
-rw-r--r-- | Build/source/texk/dvipdfm-x/ChangeLog | 10 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/dpxconf.c | 2 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/dpxconf.h | 1 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/dvi.c | 19 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/dvi.h | 1 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/dvipdfmx.c | 94 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/pdfencrypt.c | 6 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/tt_aux.c | 2 |
8 files changed, 69 insertions, 66 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog index b2cd7940c9d..2aad24c11e7 100644 --- a/Build/source/texk/dvipdfm-x/ChangeLog +++ b/Build/source/texk/dvipdfm-x/ChangeLog @@ -1,5 +1,15 @@ 2018-09-16 Shunsaku Hirata <shunsaku.hirata74@gmail.com> + * dvi.[ch], dvipdfmx.c: Fixed a bug that papersize special does + not work. (introduced in the previous change) Command line + options other than papersize now take precedence over special + command options. + * dpxconf.[ch], tt_aux.c: Moved always_embed flag to dpx_conf. + * pdfencrypt.c: Fixed a bug that calculation of encryption key + was not done properly for RC4 and revision 2-3 AES security. + +2018-09-16 Shunsaku Hirata <shunsaku.hirata74@gmail.com> + * dpxutil.[ch], dvi.[ch], dvipdfmx.c, pdfdoc.[ch], pdfencrypt.[ch], pdffont.[ch], xbb.c: Remove duplicated code. Reorganize initialization process. Use struct for passing options. diff --git a/Build/source/texk/dvipdfm-x/dpxconf.c b/Build/source/texk/dvipdfm-x/dpxconf.c index 5b2f068d46a..d8279489b2b 100644 --- a/Build/source/texk/dvipdfm-x/dpxconf.c +++ b/Build/source/texk/dvipdfm-x/dpxconf.c @@ -30,7 +30,7 @@ #include "dpxconf.h" -struct _dpx_conf dpx_conf = {0, dpx_mode_normal_mode, {0}}; +struct _dpx_conf dpx_conf = {0, dpx_mode_normal_mode, 0, {0}}; #ifndef HAVE_LIBPAPER const struct paper paperspecs[] = { diff --git a/Build/source/texk/dvipdfm-x/dpxconf.h b/Build/source/texk/dvipdfm-x/dpxconf.h index 1b50fa0a575..8a6b775692d 100644 --- a/Build/source/texk/dvipdfm-x/dpxconf.h +++ b/Build/source/texk/dvipdfm-x/dpxconf.h @@ -33,6 +33,7 @@ enum dpx_mode { extern struct _dpx_conf { int verbose_level; enum dpx_mode compat_mode; + int ignore_font_license; struct { int keep_cache; } file; diff --git a/Build/source/texk/dvipdfm-x/dvi.c b/Build/source/texk/dvipdfm-x/dvi.c index 10c9ccd890f..b9648cf12cf 100644 --- a/Build/source/texk/dvipdfm-x/dvi.c +++ b/Build/source/texk/dvipdfm-x/dvi.c @@ -2310,8 +2310,7 @@ scan_special_encrypt (int *key_bits, int32_t *permission, char *opassword, char } static int -scan_special (int has_paper_option, int has_encrypt_option, - double *wd, double *ht, double *xo, double *yo, int *lm, +scan_special (double *wd, double *ht, double *xo, double *yo, int *lm, int *majorversion, int *minorversion, int *enable_encryption, int *key_bits, int32_t *permission, char *opassword, char *upassword, @@ -2443,29 +2442,20 @@ scan_special (int has_paper_option, int has_encrypt_option, RELEASE(kv); } } else if (ns_pdf && !strcmp(q, "encrypt")) { - if (!has_encrypt_option) { - *enable_encryption = 1; - error = scan_special_encrypt(key_bits, permission, opassword, upassword, &p, endptr); - } + *enable_encryption = 1; + error = scan_special_encrypt(key_bits, permission, opassword, upassword, &p, endptr); } else if (ns_dvipdfmx && !strcmp(q, "config")) { read_config_special(&p, endptr); } RELEASE(q); } - /* Recover papersizes specified via command line option */ - if (has_paper_option) { - *wd = width; - *ht = height; - } - return error; } void dvi_scan_specials (int page_no, - int has_paper_option, int has_encrypt_option, double *page_width, double *page_height, double *x_offset, double *y_offset, int *landscape, int *majorversion, int *minorversion, @@ -2514,8 +2504,7 @@ dvi_scan_specials (int page_no, #define buf ((char*)(dvi_page_buffer + dvi_page_buf_index)) if (fread(buf, sizeof(char), size, fp) != size) ERROR("Reading DVI file failed!"); - if (scan_special(has_paper_option, has_encrypt_option, - page_width, page_height, x_offset, y_offset, landscape, + if (scan_special(page_width, page_height, x_offset, y_offset, landscape, majorversion, minorversion, do_enc, key_bits, permission, owner_pw, user_pw, buf, size)) diff --git a/Build/source/texk/dvipdfm-x/dvi.h b/Build/source/texk/dvipdfm-x/dvi.h index f1f4930d8c5..380f464e5ea 100644 --- a/Build/source/texk/dvipdfm-x/dvi.h +++ b/Build/source/texk/dvipdfm-x/dvi.h @@ -69,7 +69,6 @@ extern void dvi_dirchg(unsigned char dir); extern void dvi_do_page (double paper_height, double x_offset, double y_offset); extern void dvi_scan_specials (int page_no, - int has_paper_option, int has_encrypt_option, double *width, double *height, double *x_offset, double *y_offset, int *landscape, int *majorversion, int *minorversion, diff --git a/Build/source/texk/dvipdfm-x/dvipdfmx.c b/Build/source/texk/dvipdfm-x/dvipdfmx.c index d58bbac6b0b..cd644e646f1 100644 --- a/Build/source/texk/dvipdfm-x/dvipdfmx.c +++ b/Build/source/texk/dvipdfm-x/dvipdfmx.c @@ -115,20 +115,15 @@ double paper_height = 842.0; static double x_offset = 72.0; static double y_offset = 72.0; int landscape_mode = 0; - +static int translate_origin = 0; /* Command line option takes precedence */ static int has_paper_option = 0; static int has_encrypt_option = 0; -int always_embed = 0; /* always embed fonts, regardless of licensing flags */ - -int translate_origin = 0; - char *dvi_filename = NULL, *pdf_filename = NULL; -static void -read_config_file (const char *config); +static void read_config_file (const char *config); static void set_default_pdf_filename(void) @@ -470,10 +465,11 @@ static struct option long_options[] = { }; static void -do_early_args (int argc, char *argv[]) +do_args_first_pass (int argc, char *argv[], const char *source, int unsafe) { int c; + optind = 1; while ((c = getopt_long(argc, argv, optstrig, long_options, NULL)) != -1) { switch(c) { case 'h': @@ -491,6 +487,14 @@ do_early_args (int argc, char *argv[]) exit(0); break; + case 132: /* --dvipdfm */ + dpx_conf.compat_mode = dpx_mode_compat_mode; + break; + + case 133: /* --kpathsea-debug */ + kpathsea_debug = atoi(optarg); + break; + case 1000: /* --mvorigin */ translate_origin = 1; break; @@ -516,30 +520,30 @@ do_early_args (int argc, char *argv[]) dpx_conf.verbose_level++; } } + + if (argc > optind + 1) { + fprintf(stderr, "%s: Multiple dvi filenames?", my_name); + usage(); + } else if (argc > optind) { /* last argument */ + dvi_filename = NEW(strlen(argv[optind]) + 5, char); /* space to append ".dvi" */ + strcpy(dvi_filename, argv[optind]); + } } /* Set "unsafe" to non-zero value when parsing config specials to * disallow overriding "D" option value. */ static void -do_args (int argc, char *argv[], const char *source, int unsafe) +do_args_second_pass (int argc, char *argv[], const char *source, int unsafe) { - int c; - char *nextptr; + int c; + char *nextptr; const char *nnextptr; optind = 1; while ((c = getopt_long(argc, argv, optstrig, long_options, NULL)) != -1) { switch(c) { - case 'h': case 130: case 131: case 1000: case 'q': case 'v': /* already done */ - break; - - case 132: /* --dvipdfm */ - dpx_conf.compat_mode = dpx_mode_compat_mode; - break; - - case 133: /* --kpathsea-debug */ - kpathsea_debug = atoi(optarg); + case 'h': case 130: case 131: case 132: case 133: case 1000: case 'q': case 'v': /* already done */ break; case 'D': @@ -683,7 +687,7 @@ do_args (int argc, char *argv[], const char *source, int unsafe) } case 'E': - always_embed = 1; + dpx_conf.ignore_font_license = 1; break; case 'e': @@ -706,13 +710,7 @@ do_args (int argc, char *argv[], const char *source, int unsafe) return; } - if (argc > optind + 1) { - fprintf(stderr, "%s: Multiple dvi filenames?", my_name); - usage(); - } else if (argc > optind) { - dvi_filename = NEW(strlen(argv[optind]) + 5, char); /* space to append ".dvi" */ - strcpy(dvi_filename, argv[optind]); - } + return; } static void @@ -724,6 +722,8 @@ cleanup (void) RELEASE(pdf_filename); if (page_ranges) RELEASE(page_ranges); + if (filter_template) + RELEASE(filter_template); } static void @@ -766,7 +766,7 @@ read_config_file (const char *config) argv[2] = parse_ident (&start, end); } } - do_args (argc, argv, config, 0); + do_args_second_pass (argc, argv, config, 0); while (argc > 1) { RELEASE (argv[--argc]); } @@ -806,7 +806,7 @@ read_config_special (const char **start, const char *end) argv[2] = parse_ident (start, end); } } - do_args (argc, argv, argv0, 1); /* Set to unsafe */ + do_args_second_pass (argc, argv, argv0, 1); /* Set to unsafe */ while (argc > 1) { RELEASE (argv[--argc]); } @@ -890,9 +890,9 @@ do_dvi_pages (void) page_width = paper_width; page_height = paper_height; w = page_width; h = page_height; lm = landscape_mode; xo = x_offset; yo = y_offset; - dvi_scan_specials(page_no, has_paper_option, has_encrypt_option, + dvi_scan_specials(page_no, &w, &h, &xo, &yo, &lm, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - if (lm != landscape_mode) { + if (lm != landscape_mode) { /* already swapped for the first page */ SWAP(w, h); landscape_mode = lm; } @@ -1013,7 +1013,7 @@ main (int argc, char *argv[]) double dvi2pts; char *base; struct pdf_setting settings; - char uplain[MAX_PWD_LEN], oplain[MAX_PWD_LEN]; /* encryption password */ + char uplain[MAX_PWD_LEN+1], oplain[MAX_PWD_LEN+1]; /* encryption password */ const char *ids[4] = {NULL, NULL, NULL, NULL}; #ifdef WIN32 @@ -1065,9 +1065,11 @@ main (int argc, char *argv[]) opterr = 0; /* Special-case single option --mvorigin, --help, --showpaper, or --version, - to avoid possible diagnostics about config files, etc. - Also handle -q and -v that cannot be set in config file. */ - do_early_args(argc, argv); + * to avoid possible diagnostics about config files, etc. + * Also handle -q and -v that cannot be set in config file. + * Get input DVI file name too. + */ + do_args_first_pass(argc, argv, NULL, 0); paperinit(); system_default(); @@ -1076,8 +1078,6 @@ main (int argc, char *argv[]) read_config_file(DPX_CONFIG_FILE); - do_args (argc, argv, NULL, 0); - #ifndef MIKTEX kpse_init_prog("", font_dpi, NULL, NULL); kpse_set_program_enabled(kpse_pk_format, true, kpse_src_texmf_cnf); @@ -1111,23 +1111,27 @@ main (int argc, char *argv[]) dvi2pts = dvi_init(dvi_filename, mag); if (dvi2pts == 0.0) ERROR("dvi_init() failed!"); - ids[3] = dvi_comment(); /* Set PDF Creator entry */ - - if (do_encryption) { - get_enc_password(oplain, uplain); - } - dvi_scan_specials(0, has_paper_option, has_encrypt_option, + dvi_scan_specials(0, &paper_width, &paper_height, &x_offset, &y_offset, &landscape_mode, &pdf_version_major, &pdf_version_minor, &do_encryption, &key_bits, &permission, oplain, uplain); - if (landscape_mode) { SWAP(paper_width, paper_height); } } + /* Command-line options take precedence */ + { + int has_encrypt_special = do_encryption; + + do_args_second_pass(argc, argv, NULL, 0); + if (do_encryption && !has_encrypt_special) { + get_enc_password(oplain, uplain); + } + } + /* Encryption and Other Settings */ { #define PRODUCER \ diff --git a/Build/source/texk/dvipdfm-x/pdfencrypt.c b/Build/source/texk/dvipdfm-x/pdfencrypt.c index f34e41c0fc8..7a7f7bff63c 100644 --- a/Build/source/texk/dvipdfm-x/pdfencrypt.c +++ b/Build/source/texk/dvipdfm-x/pdfencrypt.c @@ -173,16 +173,16 @@ compute_owner_password (struct pdf_sec *p, ARC4(&arc4, 32, padded, tmp1); if (p->R >= 3) { - for (i = 1; i <= 19; i++) { + for (i = 1; i <= 19; i++) { memcpy(tmp2, tmp1, 32); for (j = 0; j < p->key_size; j++) key[j] = hash[j] ^ i; ARC4_set_key(&arc4, p->key_size, key); ARC4(&arc4, 32, tmp2, tmp1); + } } - } + memcpy(p->O, tmp1, 32); } - memcpy(p->O, hash, 32); } static void diff --git a/Build/source/texk/dvipdfm-x/tt_aux.c b/Build/source/texk/dvipdfm-x/tt_aux.c index 61cf6e2d36f..06b9c0b4a21 100644 --- a/Build/source/texk/dvipdfm-x/tt_aux.c +++ b/Build/source/texk/dvipdfm-x/tt_aux.c @@ -179,7 +179,7 @@ pdf_obj *tt_get_fontdesc (sfnt *sfont, int *embed, int stemv, int type, const ch WARN("Font \"%s\" permits \"Preview & Print\" embedding only **\n", fontname); *embed = 1; } else { - if (always_embed) { + if (dpx_conf.ignore_font_license) { if (dpx_conf.verbose_level > 0) WARN("Font \"%s\" may be subject to embedding restrictions **\n", fontname); *embed = 1; |