From 7f9ea92314477339a075bdd41c5db5d6d854b906 Mon Sep 17 00:00:00 2001 From: Tom Callaway Date: Fri, 10 Jan 2020 10:51:31 -0500 Subject: [PATCH 1/3] fix python3 issues with pdfbook2 and latex-papersize --- texlive-base-latex-papersize-py3.patch | 84 ++++++++++++++++++++++++++ texlive-base-pdfbook2-py3.patch | 11 +++- texlive-base.spec | 10 ++- 3 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 texlive-base-latex-papersize-py3.patch diff --git a/texlive-base-latex-papersize-py3.patch b/texlive-base-latex-papersize-py3.patch new file mode 100644 index 0000000..f8b9087 --- /dev/null +++ b/texlive-base-latex-papersize-py3.patch @@ -0,0 +1,84 @@ +diff -up ./scripts/latex-papersize/latex-papersize.py.py3 ./scripts/latex-papersize/latex-papersize.py +--- ./scripts/latex-papersize/latex-papersize.py.py3 2016-10-17 17:30:47.000000000 -0400 ++++ ./scripts/latex-papersize/latex-papersize.py 2019-12-14 03:02:45.000000000 -0500 +@@ -1,7 +1,7 @@ + #!/usr/bin/env python + r""" + Calculate LaTeX paper and margin settings for arbitrary magnification +-(C) Silas S. Brown, 2005-2009, 2016. Version 1.62. ++(C) Silas S. Brown, 2005-2009, 2016, 2019. Version 1.63. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. +@@ -32,6 +32,7 @@ are often meant to be clearer. + + This is a Python script to calculate the necessary + settings for arbitrary font and page sizes. ++Works in both Python 2 and Python 3. + + BASIC USAGE + +@@ -151,11 +152,16 @@ To run dvips on the .dvi file (not neede + $(python latex-papersize.py 12 26 file.dvi) + """ + +-import os, sys, math, commands ++import os, sys, math ++try: from commands import getoutput # Python 2 ++except: from subprocess import getoutput # Python 3 ++def hasKey(a,b): ++ try: return a.has_key(b) # old Python 2 ++ except: return b in a # newer Python 2 + Python 3 + if len(sys.argv)==2 and sys.argv[1]=="--help": +- print __doc__.strip() ; raise SystemExit ++ print(__doc__.strip()); raise SystemExit + if len(sys.argv)==2 and sys.argv[1]=="--version": +- print __doc__[:__doc__.find("\n\n")].strip() ; raise SystemExit ++ print(__doc__[:__doc__.find("\n\n")].strip()); raise SystemExit + + base_pointsize = float(sys.argv[1]) + desired_pointsize = float(sys.argv[2]) +@@ -167,13 +173,13 @@ else: + extra_bottom_margin_mm = 0 + pageStyle = " \\pagestyle{empty}" + +-if os.environ.has_key("paper_width"): paper_width=float(os.environ["paper_width"]) ++if hasKey(os.environ,"paper_width"): paper_width=float(os.environ["paper_width"]) + else: paper_width=210 +-if os.environ.has_key("paper_height"): paper_height=float(os.environ["paper_height"]) ++if hasKey(os.environ,"paper_height"): paper_height=float(os.environ["paper_height"]) + else: paper_height=297 +-if os.environ.has_key("margin_left"): margin_left=float(os.environ["margin_left"]) ++if hasKey(os.environ,"margin_left"): margin_left=float(os.environ["margin_left"]) + else: margin_left=10 +-if os.environ.has_key("margin_top"): margin_top=float(os.environ["margin_top"]) ++if hasKey(os.environ,"margin_top"): margin_top=float(os.environ["margin_top"]) + else: margin_top=10 + + paper_magstep = 1.0*desired_pointsize/base_pointsize +@@ -188,15 +194,16 @@ if sys.argv[3]=="tex" or sys.argv[3]=="p + s="\\textwidth=%.1fmm \\textheight=%.1fmm \\topmargin=%.1fmm \\marginparwidth=0mm \\oddsidemargin=%.1fmm \\evensidemargin=%.1fmm \\columnsep=%.1fmm%s" % (textwidth,textheight,margin_top_setting,margin_left_setting,margin_left_setting,margin_left_setting,pageStyle) + if sys.argv[3]=="pdftex": + s += "\\mag=%d \\pdfpagewidth=%d true mm \\pdfpageheight=%d true mm \\pdfhorigin=0 mm \\pdfvorigin=-12.95 mm \\paperwidth=%d true mm \\paperheight=%d true mm" % (1000*paper_magstep,paper_width,paper_height,paper_width,paper_height) # the -12.95mm seems to be a constant regardless of magnification (previous version had -14 but it sems -12.95 is more accurate - at least 12.9 is too small and 13 is too big). Need \paperwidth and \paperheight in there as well in case using hyperref. +- print s ++ print(s) + else: +- os.system("dvips -T %dmm,%dmm -x %d %s -o bbox_test.ps" % (paper_width*10,paper_height*10,1000*paper_magstep+0.5,sys.argv[3])) ++ r = os.system("dvips -T %dmm,%dmm -x %d %s -o bbox_test.ps" % (paper_width*10,paper_height*10,1000*paper_magstep+0.5,sys.argv[3])) ++ assert not r, "dvips failed" + # Now, that would have got the origin wrong. I can't + # figure out how dvips origin and magstep is supposed to + # interoperate, so let's work it out on a case-by-case + # basis from the bounding box. + # (Note: multiplying paper_width and paper_height by 10 above, because if dealing with very small paper sizes then this may give a reading of 0 if the origin is off the page. Increasing the paper size doesn't seem to affect the origin.) +- bbox=commands.getoutput("echo|gs -sDEVICE=bbox bbox_test.ps 2>&1|grep BoundingBox") ++ bbox=getoutput("echo|gs -sDEVICE=bbox bbox_test.ps 2>&1|grep BoundingBox") + # (previous version used 'head -1' to take only the first page, but that can cause 'broken pipe' errors if the file contains too many pages, and will give an incorrect result if there is only one line per page and it is indented on the first page, so we'll look at ALL the pages and take the outermost bounds. Will also look at high-resolution bounding boxes only, if available.) + if "HiResBoundingBox" in bbox: bbox=filter(lambda x:"HiRes" in x,bbox.split("\n")) + else: bbox=bbox.split("\n") +@@ -206,4 +213,4 @@ else: + os.unlink("bbox_test.ps") + existing_left_margin_mm = min(map(lambda x:x[0],bbox))*25.4/72 + existing_top_margin_mm = paper_height*10-max(map(lambda x:x[3],bbox))*25.4/72 +- print "dvips -T %dmm,%dmm -O %.1fmm,%.1fmm -x %d %s" % (paper_width,paper_height,margin_left - existing_left_margin_mm,margin_top - existing_top_margin_mm,1000*paper_magstep+0.5,sys.argv[3]) ++ print("dvips -T %dmm,%dmm -O %.1fmm,%.1fmm -x %d %s" % (paper_width,paper_height,margin_left - existing_left_margin_mm,margin_top - existing_top_margin_mm,1000*paper_magstep+0.5,sys.argv[3])) diff --git a/texlive-base-pdfbook2-py3.patch b/texlive-base-pdfbook2-py3.patch index 446ab1a..ef7f780 100644 --- a/texlive-base-pdfbook2-py3.patch +++ b/texlive-base-pdfbook2-py3.patch @@ -1,13 +1,13 @@ diff -up ./scripts/pdfbook2/pdfbook2.py3 ./scripts/pdfbook2/pdfbook2 ---- ./scripts/pdfbook2/pdfbook2.py3 2016-11-25 13:32:54.000000000 -0500 -+++ ./scripts/pdfbook2/pdfbook2 2018-12-07 14:52:49.197436113 -0500 +--- ./scripts/pdfbook2/pdfbook2.py3 2020-01-10 08:49:13.071743210 -0500 ++++ ./scripts/pdfbook2/pdfbook2 2020-01-10 08:50:18.938615714 -0500 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 """ pdfbook2 - transform pdf files to booklets This program is free software: you can redistribute it and/or modify -@@ -29,11 +29,11 @@ import shutil +@@ -29,15 +29,15 @@ import shutil def booklify( name, opts ): #------------------------------------------------------ Check if file exists @@ -22,6 +22,11 @@ diff -up ./scripts/pdfbook2/pdfbook2.py3 ./scripts/pdfbook2/pdfbook2 sys.stdout.flush() #---------------------------------------------------------- useful constants +- bboxName = "%%HiResBoundingBox:" ++ bboxName = b"%%HiResBoundingBox:" + tmpFile = ".crop-tmp.pdf" + + #------------------------------------------------- find min/max bounding box @@ -50,8 +50,8 @@ def booklify( name, opts ): p.wait() out, err = p.communicate() diff --git a/texlive-base.spec b/texlive-base.spec index a19bac9..7a48a82 100644 --- a/texlive-base.spec +++ b/texlive-base.spec @@ -21,7 +21,7 @@ Name: %{shortname}-base Version: %{source_date} -Release: 35%{?dist} +Release: 36%{?dist} Epoch: 7 Summary: TeX formatting system # The only files in the base package are directories, cache, and license texts @@ -420,6 +420,9 @@ Patch17: texlive-20180414-annocheck.patch Patch18: texlive-20180414-poppler-0.73.patch # Do not throw no file error in synctex Patch19: texlive-base-20180414-synctex-do-not-throw-no-file-error.patch +# Fix latex-papersize for python3 (thanks to upstream) +Patch20: texlive-base-latex-papersize-py3.patch + # Can't do this because it causes everything else to be noarch @@ -6561,6 +6564,8 @@ sed -i 's|\\sc |\\scshape |g' %{buildroot}%{_texdir}/texmf-dist/bibtex/bst/base/ # fix pdfbook2 for py3 pushd %{buildroot}%{_texdir}/texmf-dist patch -p1 < %{_sourcedir}/texlive-base-pdfbook2-py3.patch +# fix latex-papersize for py3 +patch -p1 < %{_sourcedir}/texlive-base-latex-papersize-py3.patch popd # config files in /etc symlinked @@ -8765,6 +8770,9 @@ done <<< "$list" %doc %{_texdir}/texmf-dist/doc/latex/yplan/ %changelog +* Thu Jan 10 2020 Tom Callaway - 7:20180414-36 +- fix python3 issues with pdfbook2 and latex-papersize + * Tue Mar 19 2019 Tom Callaway - 7:20180414-35 - do not throw no file error in synctex From 7cd645bb2fc19d8afd5375b2d026fa819cff75cb Mon Sep 17 00:00:00 2001 From: Tom Callaway Date: Wed, 5 Feb 2020 13:34:12 -0500 Subject: [PATCH 2/3] fix bz#1798119 - buffer overflow in TexOpen() function, CVE-2019-19601 --- texlive-base-20180414-CVE-2019-19601.patch | 16 ++++++++++++++++ texlive-base.spec | 8 +++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 texlive-base-20180414-CVE-2019-19601.patch diff --git a/texlive-base-20180414-CVE-2019-19601.patch b/texlive-base-20180414-CVE-2019-19601.patch new file mode 100644 index 0000000..8b247a5 --- /dev/null +++ b/texlive-base-20180414-CVE-2019-19601.patch @@ -0,0 +1,16 @@ +diff -up texlive-base-20180414/source/texk/detex/detex-src/detex.l.me texlive-base-20180414/source/texk/detex/detex-src/detex.l +--- texlive-base-20180414/source/texk/detex/detex-src/detex.l.me 2020-02-05 13:29:53.294406353 -0500 ++++ texlive-base-20180414/source/texk/detex/detex-src/detex.l 2020-02-05 13:30:24.021754001 -0500 +@@ -806,10 +806,10 @@ TexOpen(char *sbFile) + #else + if (*sbFile == '/') { /* absolute path */ + #endif +- (void)sprintf(sbFullPath, "%s", sbFile); ++ (void)snprintf(sbFullPath, PATH_MAX-1, "%s", sbFile); + iPath = csbInputPaths; /* only check once */ + } else +- (void)sprintf(sbFullPath, "%s/%s", rgsbInputPaths[iPath], sbFile); ++ (void)snprintf(sbFullPath, PATH_MAX-1, "%s/%s", rgsbInputPaths[iPath], sbFile); + #ifdef OS2 + pch = sbFullPath; + while (pch = strchr(pch, '\\')) diff --git a/texlive-base.spec b/texlive-base.spec index 7a48a82..412ee4e 100644 --- a/texlive-base.spec +++ b/texlive-base.spec @@ -21,7 +21,7 @@ Name: %{shortname}-base Version: %{source_date} -Release: 36%{?dist} +Release: 37%{?dist} Epoch: 7 Summary: TeX formatting system # The only files in the base package are directories, cache, and license texts @@ -422,6 +422,8 @@ Patch18: texlive-20180414-poppler-0.73.patch Patch19: texlive-base-20180414-synctex-do-not-throw-no-file-error.patch # Fix latex-papersize for python3 (thanks to upstream) Patch20: texlive-base-latex-papersize-py3.patch +# bz#1798119, buffer overflow, CVE-2019-19601 +Patch21: texlive-base-20180414-CVE-2019-19601.patch @@ -6414,6 +6416,7 @@ xz -dc %{SOURCE0} | tar x %patch17 -p1 -b .annocheck %patch18 -p1 -b .poppler-0.73 %patch19 -p1 -b .shh +%patch20 -p1 -b .CVE-2019-19601 # Setup copies of the licenses for l in `unxz -c %{SOURCE3} | tar t`; do @@ -8770,6 +8773,9 @@ done <<< "$list" %doc %{_texdir}/texmf-dist/doc/latex/yplan/ %changelog +* Wed Feb 5 2020 Tom Callaway - 7:20180414-37 +- fix bz#1798119 - buffer overflow in TexOpen() function, CVE-2019-19601 + * Thu Jan 10 2020 Tom Callaway - 7:20180414-36 - fix python3 issues with pdfbook2 and latex-papersize From 8e82c002a8a02d1963ca9f796bb483b608a97a7b Mon Sep 17 00:00:00 2001 From: Tom Callaway Date: Wed, 5 Feb 2020 13:52:46 -0500 Subject: [PATCH 3/3] apply right patch --- texlive-base.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/texlive-base.spec b/texlive-base.spec index 412ee4e..dcac0a7 100644 --- a/texlive-base.spec +++ b/texlive-base.spec @@ -6416,7 +6416,7 @@ xz -dc %{SOURCE0} | tar x %patch17 -p1 -b .annocheck %patch18 -p1 -b .poppler-0.73 %patch19 -p1 -b .shh -%patch20 -p1 -b .CVE-2019-19601 +%patch21 -p1 -b .CVE-2019-19601 # Setup copies of the licenses for l in `unxz -c %{SOURCE3} | tar t`; do