Package: htmldoc / 1.9.11-4+deb11u3

CVE-2021-23206.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From: Michael R Sweet <michael.r.sweet@gmail.com>
Date: Thu, 1 Apr 2021 08:21:57 -0400
Subject: CVE-2021-23206

Fix crash bugs with bogus table attributes (Issue #416)

Origin: upstream, https://github.com/michaelrsweet/htmldoc/commit/ba61a3ece382389ae4482c7027af8b32e8ab4cc8
Bug: https://github.com/michaelrsweet/htmldoc/issues/416
Bug-Debian: https://bugs.debian.org/989437
---
 htmldoc/ps-pdf.cxx | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/htmldoc/ps-pdf.cxx b/htmldoc/ps-pdf.cxx
index 499f487..bb8a5b9 100644
--- a/htmldoc/ps-pdf.cxx
+++ b/htmldoc/ps-pdf.cxx
@@ -5735,7 +5735,7 @@ render_table_row(hdtable_t &table,
       if ((var = htmlGetVariable(cells[row][col], (uchar *)"ROWSPAN")) != NULL)
         table.row_spans[col] = atoi((char *)var);
 
-      if (table.row_spans[col] == 1)
+      if (table.row_spans[col] <= 1)
         table.row_spans[col] = 0;
 
       if (table.row_spans[col] > (table.num_rows - row))
@@ -6555,7 +6555,12 @@ parse_table(tree_t *t,			// I - Tree to parse
         {
 	  // Handle colspan and rowspan stuff...
           if ((var = htmlGetVariable(tempcol, (uchar *)"COLSPAN")) != NULL)
-            colspan = atoi((char *)var);
+          {
+            if ((colspan = atoi((char *)var)) < 1)
+              colspan = 1;
+            else if (colspan > (MAX_COLUMNS - col))
+              colspan = MAX_COLUMNS - col;
+          }
           else
             colspan = 1;
 
@@ -6563,7 +6568,7 @@ parse_table(tree_t *t,			// I - Tree to parse
 	  {
             table.row_spans[col] = atoi((char *)var);
 
-	    if (table.row_spans[col] == 1)
+	    if (table.row_spans[col] <= 1)
 	      table.row_spans[col] = 0;
 
 	    for (tcol = 1; tcol < colspan; tcol ++)
@@ -6585,6 +6590,11 @@ parse_table(tree_t *t,			// I - Tree to parse
 	    {
               col_width -= 2.0 * table.cellpadding;
 	    }
+
+	    if (col_width <= 0.0f)
+	      col_width = 0.0f;
+	    else if (col_width > PageWidth)
+	      col_width = PageWidth;
 	  }
 	  else
 	    col_width = 0.0f;