From 7de052bbeb0f182212faaf796d13ebb07e4bd2c8 Mon Sep 17 00:00:00 2001 From: linker Date: Tue, 11 May 2021 14:48:25 +0800 Subject: [PATCH] fix cve-2020-18032 --- backport-CVE-2020-18032.patch | 40 +++++++++++++++++++++++++++++++++++ graphviz.spec | 10 ++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 backport-CVE-2020-18032.patch diff --git a/backport-CVE-2020-18032.patch b/backport-CVE-2020-18032.patch new file mode 100644 index 0000000..b3b0ab9 --- /dev/null +++ b/backport-CVE-2020-18032.patch @@ -0,0 +1,40 @@ +From 784411ca3655c80da0f6025ab20634b2a6ff696b Mon Sep 17 00:00:00 2001 +From: Matthew Fernandez +Date: Sat, 25 Jul 2020 19:31:01 -0700 +Subject: [PATCH] fix: out-of-bounds write on invalid label + +When the label for a node cannot be parsed (due to it being malformed), it falls +back on the symbol name of the node itself. I.e. the default label the node +would have had if it had no label attribute at all. However, this is applied by +dynamically altering the node's label to "\N", a shortcut for the symbol name of +the node. All of this is fine, however if the hand written label itself is +shorter than the literal string "\N", not enough memory would have been +allocated to write "\N" into the label text. + +Here we account for the possibility of error during label parsing, and assume +that the label text may need to be overwritten with "\N" after the fact. Fixes +issue #1700. +--- + lib/common/shapes.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/lib/common/shapes.c b/lib/common/shapes.c +index 0a0635fc3..9dca9ba6e 100644 +--- a/lib/common/shapes.c ++++ b/lib/common/shapes.c +@@ -3546,9 +3546,10 @@ static void record_init(node_t * n) + reclblp = ND_label(n)->text; + len = strlen(reclblp); + /* For some forgotten reason, an empty label is parsed into a space, so +- * we need at least two bytes in textbuf. ++ * we need at least two bytes in textbuf, as well as accounting for the ++ * error path involving "\\N" below. + */ +- len = MAX(len, 1); ++ len = MAX(MAX(len, 1), (int)strlen("\\N")); + textbuf = N_NEW(len + 1, char); + if (!(info = parse_reclbl(n, flip, TRUE, textbuf))) { + agerr(AGERR, "bad label format %s\n", ND_label(n)->text); +-- +GitLab + diff --git a/graphviz.spec b/graphviz.spec index 1add4cd..5dc6c0c 100644 --- a/graphviz.spec +++ b/graphviz.spec @@ -16,7 +16,7 @@ Name: graphviz Version: 2.44.0 -Release: 1 +Release: 2 Summary: Graph Visualization Tools License: EPL URL: http://www.graphviz.org/ @@ -24,6 +24,8 @@ Source0: https://gitlab.com/graphviz/graphviz/-/archive/%{version}/gr Patch1: graphviz-2.40.1-dotty-menu-fix.patch +Patch6000: backport-CVE-2020-18032.patch + BuildRequires: ksh bison m4 flex ruby automake perl-Carp autoconf libtool qpdf ocaml urw-base35-fonts, perl-ExtUtils-Embed, perl-generators, librsvg2-devel swig >= 1.3.33 BuildRequires: zlib-devel libpng-devel libjpeg-devel expat-devel tk-devel fontconfig-devel libtool-ltdl-devel ruby-devel guile-devel freetype-devel >= 2 tcl-devel >= 8.3 BuildRequires: python3-devel libXaw-devel libSM-devel libXext-devel java-devel pango-devel gmp-devel lua-devel gtk2-devel cairo-devel >= 1.1.10 @@ -311,6 +313,12 @@ php --no-php-ini --define extension_dir=$RPM_BUILD_ROOT%{_libdir}/graphviz/php/ %changelog +* Thu May 11 2021 wangkerong - 2.44.0-2 +- Type:CVE +- ID:CVE-2020-18032 +- SUG:NA +- DESC:fix CVE-2020-18032 + * Thu Aug 20 2020 jinzhimin - 2.44.0-1 - Type:update - ID:NA -- Gitee