Browse code

libtiif: Fix CVE-2022-1622

Change-Id: I0e86b9858b46ea06328cd2267a96ac2a4d9c5433
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/16679
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Keerthana K <keerthanak@vmware.com>

Shivani Agarwal authored on 2022/06/20 16:16:33
Showing 11 changed files
... ...
@@ -1,14 +1,14 @@
1 1
 Summary:        GD is an open source code library for the dynamic creation of images by programmers.
2 2
 Name:           libgd
3 3
 Version:        2.3.2
4
-Release:        3%{?dist}
4
+Release:        4%{?dist}
5 5
 License:        MIT
6 6
 URL:            https://libgd.github.io/
7 7
 Group:          System/Libraries
8 8
 Vendor:         VMware, Inc.
9 9
 Distribution:   Photon
10 10
 Source0:        https://github.com/libgd/libgd/releases/download/gd-%{version}/%{name}-%{version}.tar.gz
11
-%define sha1    libgd=be6da7d9d58ff09d5d28f4fc2763aef4f0c3c75f
11
+%define sha512  libgd=8295dfe1ef0a23aeb4d14cc6a2977ff3c6e3835e3f37f6a0eb13b313b5ab31a8751534473c34ac29ef18307611aa4df9f5421b9fd5b7cee650e197988ecdfdd9
12 12
 Patch0:         libgd-CVE-2021-38115.patch
13 13
 Patch1:         libgd-CVE-2021-40145.patch
14 14
 Patch2:         libgd-CVE-2021-40812.patch
... ...
@@ -64,6 +64,8 @@ make %{?_smp_mflags} -k check
64 64
 %{_libdir}/pkgconfig/*
65 65
 
66 66
 %changelog
67
+*   Mon Jun 20 2022 Shivani Agarwal <shivania2@vmware.com>  2.3.2-4
68
+-   Version bump up to use libtiff 4.4.0
67 69
 *   Fri Sep 24 2021 Nitesh Kumar <kunitesh@vmware.com> 2.3.2-3
68 70
 -   Patched for CVE-2021-40812.
69 71
 *   Wed Sep 08 2021 Nitesh Kumar <kunitesh@vmware.com> 2.3.2-2
... ...
@@ -1,6 +1,8 @@
1
-+++ b/autogen.sh	2021-04-27 20:07:41.237138194 +0000
2
-@@ -5,16 +5,3 @@
1
+diff --git a/autogen.sh b/autogen.sh
2
+index 2882bfc7..db8c38e7 100755
3
+--- a/autogen.sh
4
+@@ -5,16 +5,3 @@ aclocal -I ./m4
3 5
  autoheader
4 6
  automake --foreign --add-missing --copy
5 7
  autoconf
... ...
@@ -11,7 +13,7 @@
11 11
 -    echo "$0: getting $file..."
12 12
 -    wget -q --timeout=5 -O config/$file.tmp \
13 13
 -      "https://git.savannah.gnu.org/cgit/config.git/plain/${file}" \
14
--      && mv config/$file.tmp config/$file \
14
+-      && mv -f config/$file.tmp config/$file \
15 15
 -      && chmod a+x config/$file
16 16
 -    retval=$?
17 17
 -    rm -f config/$file.tmp
18 18
deleted file mode 100644
... ...
@@ -1,31 +0,0 @@
1
-From a1c933dabd0e1c54a412f3f84ae0aa58115c6067 Mon Sep 17 00:00:00 2001
2
-From: Even Rouault <even.rouault@spatialys.com>
3
-Date: Thu, 24 Feb 2022 22:26:02 +0100
4
-Subject: [PATCH] tif_jbig.c: fix crash when reading a file with multiple IFD
5
- in memory-mapped mode and when bit reversal is needed (fixes #385)
6
-
7
- libtiff/tif_jbig.c | 10 ++++++++++
8
- 1 file changed, 10 insertions(+)
9
-
10
-diff --git a/libtiff/tif_jbig.c b/libtiff/tif_jbig.c
11
-index 740863384c569b17f4dfc01ee580853e3270af6c..8bfa4cef6ddb8a10021c51f12b17d82381269a49 100644
12
-+++ b/libtiff/tif_jbig.c
13
-@@ -209,6 +209,16 @@ int TIFFInitJBIG(TIFF* tif, int scheme)
14
- 	 */
15
- 	tif->tif_flags |= TIFF_NOBITREV;
16
- 	tif->tif_flags &= ~TIFF_MAPPED;
17
-+	/* We may have read from a previous IFD and thus set TIFF_BUFFERMMAP and
18
-+	 * cleared TIFF_MYBUFFER. It is necessary to restore them to their initial
19
-+	 * value to be consistent with the state of a non-memory mapped file.
20
-+	 */
21
-+	if (tif->tif_flags&TIFF_BUFFERMMAP) {
22
-+		tif->tif_rawdata = NULL;
23
-+		tif->tif_rawdatasize = 0;
24
-+		tif->tif_flags &= ~TIFF_BUFFERMMAP;
25
-+		tif->tif_flags |= TIFF_MYBUFFER;
26
-+	}
27
- 
28
- 	/* Setup the function pointers for encode, decode, and cleanup. */
29
- 	tif->tif_setupdecode = JBIGSetupDecode;
30 1
deleted file mode 100644
... ...
@@ -1,213 +0,0 @@
1
-From 232282fd8f9c21eefe8d2d2b96cdbbb172fe7b7c Mon Sep 17 00:00:00 2001
2
-From: Su Laus <sulau@freenet.de>
3
-Date: Tue, 8 Mar 2022 17:02:44 +0000
4
-Subject: [PATCH] tiffcrop: fix issue #380 and #382 heap buffer overflow in
5
- extractImageSection
6
-
7
- tools/tiffcrop.c | 92 +++++++++++++++++++-----------------------------
8
- 1 file changed, 36 insertions(+), 56 deletions(-)
9
-
10
-diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
11
-index f2e5474a..e62bcc71 100644
12
-+++ b/tools/tiffcrop.c
13
-@@ -105,8 +105,8 @@
14
-  *                of messages to monitor progress without enabling dump logs.
15
-  */
16
- 
17
--static   char tiffcrop_version_id[] = "2.4";
18
--static   char tiffcrop_rev_date[] = "12-13-2010";
19
-+static   char tiffcrop_version_id[] = "2.4.1";
20
-+static   char tiffcrop_rev_date[] = "03-03-2010";
21
- 
22
- #include "tif_config.h"
23
- #include "libport.h"
24
-@@ -6739,10 +6739,10 @@ extractImageSection(struct image_data *image, struct pageseg *section,
25
- #ifdef DEVELMODE
26
-   uint32_t    img_length;
27
- #endif
28
--  uint32_t    j, shift1, shift2, trailing_bits;
29
-+  uint32_t    j, shift1, trailing_bits;
30
-   uint32_t    row, first_row, last_row, first_col, last_col;
31
-   uint32_t    src_offset, dst_offset, row_offset, col_offset;
32
--  uint32_t    offset1, offset2, full_bytes;
33
-+  uint32_t    offset1, full_bytes;
34
-   uint32_t    sect_width;
35
- #ifdef DEVELMODE
36
-   uint32_t    sect_length;
37
-@@ -6752,7 +6752,6 @@ extractImageSection(struct image_data *image, struct pageseg *section,
38
- #ifdef DEVELMODE
39
-   int      k;
40
-   unsigned char bitset;
41
--  static char *bitarray = NULL;
42
- #endif
43
- 
44
-   img_width = image->width;
45
-@@ -6770,17 +6769,12 @@ extractImageSection(struct image_data *image, struct pageseg *section,
46
-   dst_offset = 0;
47
- 
48
- #ifdef DEVELMODE
49
--  if (bitarray == NULL)
50
--    {
51
--    if ((bitarray = (char *)malloc(img_width)) == NULL)
52
--      {
53
--      TIFFError ("", "DEBUG: Unable to allocate debugging bitarray");
54
--      return (-1);
55
--      }
56
--    }
57
-+  char bitarray[39];
58
- #endif
59
- 
60
--  /* rows, columns, width, length are expressed in pixels */
61
-+  /* rows, columns, width, length are expressed in pixels
62
-+   * first_row, last_row, .. are index into image array starting at 0 to width-1,
63
-+   * last_col shall be also extracted.  */
64
-   first_row = section->y1;
65
-   last_row  = section->y2;
66
-   first_col = section->x1;
67
-@@ -6790,9 +6784,14 @@ extractImageSection(struct image_data *image, struct pageseg *section,
68
- #ifdef DEVELMODE
69
-   sect_length = last_row - first_row + 1;
70
- #endif
71
--  img_rowsize = ((img_width * bps + 7) / 8) * spp;
72
--  full_bytes = (sect_width * spp * bps) / 8;   /* number of COMPLETE bytes per row in section */
73
--  trailing_bits = (sect_width * bps) % 8;
74
-+    /* The read function loadImage() used copy separate plane data into a buffer as interleaved
75
-+     * samples rather than separate planes so the same logic works to extract regions
76
-+     * regardless of the way the data are organized in the input file.
77
-+     * Furthermore, bytes and bits are arranged in buffer according to COMPRESSION=1 and FILLORDER=1 
78
-+     */
79
-+    img_rowsize = (((img_width * spp * bps) + 7) / 8);    /* row size in full bytes of source image */
80
-+    full_bytes = (sect_width * spp * bps) / 8;            /* number of COMPLETE bytes per row in section */
81
-+    trailing_bits = (sect_width * spp * bps) % 8;         /* trailing bits within the last byte of destination buffer */
82
- 
83
- #ifdef DEVELMODE
84
-     TIFFError ("", "First row: %"PRIu32", last row: %"PRIu32", First col: %"PRIu32", last col: %"PRIu32"\n",
85
-@@ -6805,10 +6804,9 @@ extractImageSection(struct image_data *image, struct pageseg *section,
86
- 
87
-   if ((bps % 8) == 0)
88
-     {
89
--    col_offset = first_col * spp * bps / 8;
90
-+    col_offset = (first_col * spp * bps) / 8;
91
-     for (row = first_row; row <= last_row; row++)
92
-       {
93
--      /* row_offset = row * img_width * spp * bps / 8; */
94
-       row_offset = row * img_rowsize;
95
-       src_offset = row_offset + col_offset;
96
- 
97
-@@ -6821,14 +6819,12 @@ extractImageSection(struct image_data *image, struct pageseg *section,
98
-     }
99
-   else
100
-     { /* bps != 8 */
101
--    shift1  = spp * ((first_col * bps) % 8);
102
--    shift2  = spp * ((last_col * bps) % 8);
103
-+    shift1 = ((first_col * spp * bps) % 8);           /* shift1 = bits to skip in the first byte of source buffer*/
104
-     for (row = first_row; row <= last_row; row++)
105
-       {
106
-       /* pull out the first byte */
107
-       row_offset = row * img_rowsize;
108
--      offset1 = row_offset + (first_col * bps / 8);
109
--      offset2 = row_offset + (last_col * bps / 8);
110
-+      offset1 = row_offset + ((first_col * spp * bps) / 8);   /* offset1 = offset into source of byte with first bits to be extracted */
111
- 
112
- #ifdef DEVELMODE
113
-       for (j = 0, k = 7; j < 8; j++, k--)
114
-@@ -6840,12 +6836,12 @@ extractImageSection(struct image_data *image, struct pageseg *section,
115
-       sprintf(&bitarray[9], " ");
116
-       for (j = 10, k = 7; j < 18; j++, k--)
117
-         {
118
--        bitset = *(src_buff + offset2) & (((unsigned char)1 << k)) ? 1 : 0;
119
-+        bitset = *(src_buff + offset1 + full_bytes) & (((unsigned char)1 << k)) ? 1 : 0;
120
-         sprintf(&bitarray[j], (bitset) ? "1" : "0");
121
-         }
122
-       bitarray[18] = '\0';
123
--      TIFFError ("", "Row: %3d Offset1: %"PRIu32",  Shift1: %"PRIu32",    Offset2: %"PRIu32",  Shift2:  %"PRIu32"\n", 
124
--                 row, offset1, shift1, offset2, shift2); 
125
-+      TIFFError ("", "Row: %3d Offset1: %"PRIu32",  Shift1: %"PRIu32",    Offset2: %"PRIu32",  Trailing_bits:  %"PRIu32"\n", 
126
-+                 row, offset1, shift1, offset1+full_bytes, trailing_bits); 
127
- #endif
128
- 
129
-       bytebuff1 = bytebuff2 = 0;
130
-@@ -6869,11 +6865,12 @@ extractImageSection(struct image_data *image, struct pageseg *section,
131
- 
132
-         if (trailing_bits != 0)
133
-           {
134
--	  bytebuff2 = src_buff[offset2] & ((unsigned char)255 << (7 - shift2));
135
-+      /* Only copy higher bits of samples and mask lower bits of not wanted column samples to zero */
136
-+	  bytebuff2 = src_buff[offset1 + full_bytes] & ((unsigned char)255 << (8 - trailing_bits));
137
-           sect_buff[dst_offset] = bytebuff2;
138
- #ifdef DEVELMODE
139
- 	  TIFFError ("", "        Trailing bits src offset:  %8"PRIu32", Dst offset: %8"PRIu32"\n",
140
--                              offset2, dst_offset); 
141
-+          offset1 + full_bytes, dst_offset);
142
-           for (j = 30, k = 7; j < 38; j++, k--)
143
-             {
144
-             bitset = *(sect_buff + dst_offset) & (((unsigned char)1 << k)) ? 1 : 0;
145
-@@ -6892,8 +6889,10 @@ extractImageSection(struct image_data *image, struct pageseg *section,
146
- #endif
147
-         for (j = 0; j <= full_bytes; j++) 
148
-           {
149
--	  bytebuff1 = src_buff[offset1 + j] & ((unsigned char)255 >> shift1);
150
--	  bytebuff2 = src_buff[offset1 + j + 1] & ((unsigned char)255 << (7 - shift1));
151
-+          /* Skip the first shift1 bits and shift the source up by shift1 bits before save to destination.*/
152
-+          /* Attention: src_buff size needs to be some bytes larger than image size, because could read behind image here. */
153
-+          bytebuff1 = src_buff[offset1 + j] & ((unsigned char)255 >> shift1);
154
-+          bytebuff2 = src_buff[offset1 + j + 1] & ((unsigned char)255 << (8 - shift1));
155
-           sect_buff[dst_offset + j] = (bytebuff1 << shift1) | (bytebuff2 >> (8 - shift1));
156
-           }
157
- #ifdef DEVELMODE
158
-@@ -6909,36 +6908,17 @@ extractImageSection(struct image_data *image, struct pageseg *section,
159
- #endif
160
-         dst_offset += full_bytes;
161
- 
162
-+        /* Copy the trailing_bits for the last byte in the destination buffer. 
163
-+           Could come from one ore two bytes of the source buffer. */
164
-         if (trailing_bits != 0)
165
-           {
166
- #ifdef DEVELMODE
167
--	    TIFFError ("", "        Trailing bits   src offset: %8"PRIu32", Dst offset: %8"PRIu32"\n", offset1 + full_bytes, dst_offset);
168
--#endif
169
--	  if (shift2 > shift1)
170
--            {
171
--	    bytebuff1 = src_buff[offset1 + full_bytes] & ((unsigned char)255 << (7 - shift2));
172
--            bytebuff2 = bytebuff1 & ((unsigned char)255 << shift1);
173
--            sect_buff[dst_offset] = bytebuff2;
174
--#ifdef DEVELMODE
175
--	    TIFFError ("", "        Shift2 > Shift1\n"); 
176
-+          TIFFError("", "        Trailing bits %4"PRIu32"   src offset: %8"PRIu32", Dst offset: %8"PRIu32"\n", trailing_bits, offset1 + full_bytes, dst_offset);
177
- #endif
178
-+          /* More than necessary bits are already copied into last destination buffer, 
179
-+           * only masking of last byte in destination buffer is necessary.*/ 
180
-+          sect_buff[dst_offset] &= ((uint8_t)0xFF << (8 - trailing_bits));
181
-             }
182
--          else
183
--            {
184
--	    if (shift2 < shift1)
185
--              {
186
--              bytebuff2 = ((unsigned char)255 << (shift1 - shift2 - 1));
187
--	      sect_buff[dst_offset] &= bytebuff2;
188
--#ifdef DEVELMODE
189
--	      TIFFError ("", "        Shift2 < Shift1\n"); 
190
--#endif
191
--              }
192
--#ifdef DEVELMODE
193
--            else
194
--	      TIFFError ("", "        Shift2 == Shift1\n"); 
195
--#endif
196
--            }
197
--	  }
198
- #ifdef DEVELMODE
199
- 	  sprintf(&bitarray[28], " ");
200
- 	  sprintf(&bitarray[29], " ");
201
-@@ -7091,7 +7071,7 @@ writeImageSections(TIFF *in, TIFF *out, struct image_data *image,
202
-     width  = sections[i].x2 - sections[i].x1 + 1;
203
-     length = sections[i].y2 - sections[i].y1 + 1;
204
-     sectsize = (uint32_t)
205
--	    ceil((width * image->bps + 7) / (double)8) * image->spp * length;
206
-+	    ceil((width * image->bps * image->spp + 7) / (double)8) * length;
207
-     /* allocate a buffer if we don't have one already */
208
-     if (createImageSection(sectsize, sect_buff_ptr))
209
-       {
210
-GitLab
211 1
deleted file mode 100644
... ...
@@ -1,86 +0,0 @@
1
-From 40b00cfb32256d377608b4d4cd30fac338d0a0bc Mon Sep 17 00:00:00 2001
2
-From: Augustus <wangdw.augustus@qq.com>
3
-Date: Mon, 7 Mar 2022 18:21:49 +0800
4
-Subject: [PATCH] add checks for return value of limitMalloc (#392)
5
-
6
- tools/tiffcrop.c | 33 +++++++++++++++++++++------------
7
- 1 file changed, 21 insertions(+), 12 deletions(-)
8
-
9
-diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
10
-index f2e5474aee6762f2b0ec1e60d4320197e7ac643f..9b8acc7ec27f8ba663df92db5035dd06edef749f 100644
11
-+++ b/tools/tiffcrop.c
12
-@@ -7406,7 +7406,11 @@ createImageSection(uint32_t sectsize, unsigned char **sect_buff_ptr)
13
-   if (!sect_buff)
14
-     {
15
-     sect_buff = (unsigned char *)limitMalloc(sectsize);
16
--    *sect_buff_ptr = sect_buff;
17
-+    if (!sect_buff)
18
-+    {
19
-+        TIFFError("createImageSection", "Unable to allocate/reallocate section buffer");
20
-+        return (-1);
21
-+    }
22
-     _TIFFmemset(sect_buff, 0, sectsize);
23
-     }
24
-   else
25
-@@ -7422,15 +7426,15 @@ createImageSection(uint32_t sectsize, unsigned char **sect_buff_ptr)
26
-       else
27
-         sect_buff = new_buff;
28
- 
29
-+      if (!sect_buff)
30
-+      {
31
-+          TIFFError("createImageSection", "Unable to allocate/reallocate section buffer");
32
-+          return (-1);
33
-+      }
34
-       _TIFFmemset(sect_buff, 0, sectsize);
35
-       }
36
-     }
37
- 
38
--  if (!sect_buff)
39
--    {
40
--    TIFFError("createImageSection", "Unable to allocate/reallocate section buffer");
41
--    return (-1);
42
--    }
43
-   prev_sectsize = sectsize;
44
-   *sect_buff_ptr = sect_buff;
45
- 
46
-@@ -7697,7 +7701,11 @@ createCroppedImage(struct image_data *image, struct crop_mask *crop,
47
-   if (!crop_buff)
48
-     {
49
-     crop_buff = (unsigned char *)limitMalloc(cropsize);
50
--    *crop_buff_ptr = crop_buff;
51
-+    if (!crop_buff)
52
-+    {
53
-+        TIFFError("createCroppedImage", "Unable to allocate/reallocate crop buffer");
54
-+        return (-1);
55
-+    }
56
-     _TIFFmemset(crop_buff, 0, cropsize);
57
-     prev_cropsize = cropsize;
58
-     }
59
-@@ -7713,15 +7721,15 @@ createCroppedImage(struct image_data *image, struct crop_mask *crop,
60
-         }
61
-       else
62
-         crop_buff = new_buff;
63
-+      if (!crop_buff)
64
-+      {
65
-+          TIFFError("createCroppedImage", "Unable to allocate/reallocate crop buffer");
66
-+          return (-1);
67
-+      }
68
-       _TIFFmemset(crop_buff, 0, cropsize);
69
-       }
70
-     }
71
- 
72
--  if (!crop_buff)
73
--    {
74
--    TIFFError("createCroppedImage", "Unable to allocate/reallocate crop buffer");
75
--    return (-1);
76
--    }
77
-   *crop_buff_ptr = crop_buff;
78
- 
79
-   if (crop->crop_mode & CROP_INVERT)
80
-@@ -9280,3 +9288,4 @@ invertImage(uint16_t photometric, uint16_t spp, uint16_t bps, uint32_t width, ui
81
-  * fill-column: 78
82
-  * End:
83
-  */
84
-+
85 1
deleted file mode 100644
... ...
@@ -1,26 +0,0 @@
1
-From a95b799f65064e4ba2e2dfc206808f86faf93e85 Mon Sep 17 00:00:00 2001
2
-From: Even Rouault <even.rouault@spatialys.com>
3
-Date: Thu, 17 Feb 2022 15:28:43 +0100
4
-Subject: [PATCH] TIFFFetchNormalTag(): avoid calling memcpy() with a null
5
- source pointer and size of zero (fixes #383)
6
-
7
- libtiff/tif_dirread.c | 5 ++++-
8
- 1 file changed, 4 insertions(+), 1 deletion(-)
9
-
10
-diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
11
-index 50ebf8ac5b800f7b16e98d29f7e99b83056444c5..2ec44a4f13e14afad4c5ed40fdbf6398123c8782 100644
12
-+++ b/libtiff/tif_dirread.c
13
-@@ -5091,7 +5091,10 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
14
- 								_TIFFfree(data);
15
- 							return(0);
16
- 						}
17
--						_TIFFmemcpy(o,data,(uint32_t)dp->tdir_count);
18
-+						if (dp->tdir_count > 0 )
19
-+						{
20
-+							_TIFFmemcpy(o,data,(uint32_t)dp->tdir_count);
21
-+						}
22
- 						o[(uint32_t)dp->tdir_count]=0;
23
- 						if (data!=0)
24
- 							_TIFFfree(data);
25 1
deleted file mode 100644
... ...
@@ -1,29 +0,0 @@
1
-From 5c663c84f8a83ba790250a0ede847aa255825414 Mon Sep 17 00:00:00 2001
2
-From: Augustus <wangdw.augustus@qq.com>
3
-Date: Thu, 3 Mar 2022 16:06:58 +0800
4
-Subject: [PATCH] fix FPE in tiffcrop
5
-
6
- libtiff/tif_dir.c | 4 ++--
7
- 1 file changed, 2 insertions(+), 2 deletions(-)
8
-
9
-diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c
10
-index 57055ca90ac1efd4fabea1a2001a5dc77937951f..59b346ca15efc2105ed3920e9ba0f030e6ae23d8 100644
11
-+++ b/libtiff/tif_dir.c
12
-@@ -333,13 +333,13 @@ _TIFFVSetField(TIFF* tif, uint32_t tag, va_list ap)
13
- 		break;
14
- 	case TIFFTAG_XRESOLUTION:
15
-         dblval = va_arg(ap, double);
16
--        if( dblval < 0 )
17
-+        if( dblval != dblval || dblval < 0 )
18
-             goto badvaluedouble;
19
- 		td->td_xresolution = _TIFFClampDoubleToFloat( dblval );
20
- 		break;
21
- 	case TIFFTAG_YRESOLUTION:
22
-         dblval = va_arg(ap, double);
23
--        if( dblval < 0 )
24
-+        if( dblval != dblval || dblval < 0 )
25
-             goto badvaluedouble;
26
- 		td->td_yresolution = _TIFFClampDoubleToFloat( dblval );
27
- 		break;
28 1
deleted file mode 100644
... ...
@@ -1,51 +0,0 @@
1
-From a8a951abda9e79dafdc021f12a18e2858f474556 Mon Sep 17 00:00:00 2001
2
-From: Augustus <wangdw.augustus@qq.com>
3
-Date: Thu, 10 Mar 2022 16:41:58 +0800
4
-Subject: [PATCH] fix heap-buffer-overflow error in tiffcp by adding checks for
5
- ((bps%8)!=0)
6
-
7
- tools/tiffcp.c | 17 ++++++++++++++++-
8
- 1 file changed, 16 insertions(+), 1 deletion(-)
9
-
10
-diff --git a/tools/tiffcp.c b/tools/tiffcp.c
11
-index 224583e068159e49b9acf5fa65aeab635d4e708b..aa32b11834a45c7a094871b2d42bb38787d3cb14 100644
12
-+++ b/tools/tiffcp.c
13
-@@ -1667,12 +1667,27 @@ DECLAREwriteFunc(writeBufferToSeparateStrips)
14
- 	tdata_t obuf;
15
- 	tstrip_t strip = 0;
16
- 	tsample_t s;
17
-+	uint16_t bps = 0, bytes_per_sample;
18
- 
19
- 	obuf = limitMalloc(stripsize);
20
- 	if (obuf == NULL)
21
- 		return (0);
22
- 	_TIFFmemset(obuf, 0, stripsize);
23
- 	(void) TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
24
-+	(void) TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps);
25
-+	if( bps == 0 )
26
-+        {
27
-+            TIFFError(TIFFFileName(out), "Error, cannot read BitsPerSample");
28
-+            _TIFFfree(obuf);
29
-+            return 0;
30
-+        }
31
-+        if( (bps % 8) != 0 )
32
-+        {
33
-+            TIFFError(TIFFFileName(out), "Error, cannot handle BitsPerSample that is not a multiple of 8");
34
-+            _TIFFfree(obuf);
35
-+            return 0;
36
-+        }
37
-+	bytes_per_sample = bps/8;
38
- 	for (s = 0; s < spp; s++) {
39
- 		uint32_t row;
40
- 		for (row = 0; row < imagelength; row += rowsperstrip) {
41
-@@ -1682,7 +1697,7 @@ DECLAREwriteFunc(writeBufferToSeparateStrips)
42
- 
43
- 			cpContigBufToSeparateBuf(
44
- 			    obuf, (uint8_t*) buf + row * rowsize + s,
45
--			    nrows, imagewidth, 0, 0, spp, 1);
46
-+			    nrows, imagewidth, 0, 0, spp, bytes_per_sample);
47
- 			if (TIFFWriteEncodedStrip(out, strip++, obuf, stripsize) < 0) {
48
- 				TIFFError(TIFFFileName(out),
49
- 				    "Error, can't write strip %"PRIu32,
50 1
deleted file mode 100644
... ...
@@ -1,35 +0,0 @@
1
-From 49b81e99704bd199a24ccce65f974cc2d78cccc4 Mon Sep 17 00:00:00 2001
2
-From: 4ugustus <wangdw.augustus@qq.com>
3
-Date: Tue, 4 Jan 2022 11:01:37 +0000
4
-Subject: [PATCH 1/3] fixing global-buffer-overflow in tiffset
5
-
6
- tools/tiffset.c | 16 +++++++++++++---
7
- 1 file changed, 13 insertions(+), 3 deletions(-)
8
-
9
-index 8c9e23c5275fd958b7ff7ac0f6c2b38c826e1fcd..e7a88c09ce19c450535063177d72adf145b46603 100644
10
-+++ b/tools/tiffset.c
11
-@@ -146,9 +146,19 @@ main(int argc, char* argv[])
12
- 
13
-             arg_index++;
14
-             if (TIFFFieldDataType(fip) == TIFF_ASCII) {
15
--                if (TIFFSetField(tiff, TIFFFieldTag(fip), argv[arg_index]) != 1)
16
--                    fprintf( stderr, "Failed to set %s=%s\n",
17
--                             TIFFFieldName(fip), argv[arg_index] );
18
-+                if(TIFFFieldPassCount( fip )) {
19
-+                    size_t len;
20
-+                    len = strlen(argv[arg_index]) + 1;
21
-+                    if (len > UINT16_MAX || TIFFSetField(tiff, TIFFFieldTag(fip),
22
-+                            (uint16_t)len, argv[arg_index]) != 1)
23
-+                        fprintf( stderr, "Failed to set %s=%s\n",
24
-+                            TIFFFieldName(fip), argv[arg_index] );
25
-+                } else {
26
-+                    if (TIFFSetField(tiff, TIFFFieldTag(fip),
27
-+                            argv[arg_index]) != 1)
28
-+                        fprintf( stderr, "Failed to set %s=%s\n",
29
-+                            TIFFFieldName(fip), argv[arg_index] );
30
-+                }
31
-             } else if (TIFFFieldWriteCount(fip) > 0
32
- 		       || TIFFFieldWriteCount(fip) == TIFF_VARIABLE) {
33
-                 int     ret = 1;
... ...
@@ -1,25 +1,18 @@
1 1
 Summary:        TIFF libraries and associated utilities.
2 2
 Name:           libtiff
3
-Version:        4.3.0
4
-Release:        2%{?dist}
3
+Version:        4.4.0
4
+Release:        1%{?dist}
5 5
 License:        libtiff
6 6
 URL:            https://gitlab.com/libtiff/libtiff
7 7
 Group:          System Environment/Libraries
8 8
 Vendor:         VMware, Inc.
9 9
 Distribution:   Photon
10 10
 Source0:        https://gitlab.com/libtiff/libtiff/-/archive/v%{version}/libtiff-v%{version}.tar.gz
11
-%define sha512  libtiff-v=eaa2503dc1805283e0590b06e3e660a793fe849ae8b975b2d69369695d65a40640787c156574faaca856917be799eeb844e60f55555e1f219dd513cef66ea95d
11
+%define sha512  libtiff-v=93955a2b802cf243e41d49048499da73862b5d3ffc005e3eddf0bf948a8bd1537f7c9e7f112e72d082549b4c49e256b9da9a3b6d8039ad8fc5c09a941b7e75d7
12 12
 Source1:        config.guess
13 13
 Source2:        config.sub
14 14
 Patch0:         CVE-2018-12900.patch
15 15
 Patch1:         autogen.patch
16
-Patch2:         libtiff-CVE-2022-0891.patch
17
-Patch3:         libtiff-CVE-2022-22844.patch
18
-Patch4:         libtiff-CVE-2022-0865.patch
19
-Patch5:         libtiff-CVE-2022-0924.patch
20
-Patch6:         libtiff-CVE-2022-0908.patch
21
-Patch7:         libtiff-CVE-2022-0909.patch
22
-Patch8:         libtiff-CVE-2022-0907.patch
23 16
 BuildRequires:  libjpeg-turbo-devel wget
24 17
 Requires:       libjpeg-turbo
25 18
 
... ...
@@ -74,6 +67,8 @@ make %{?_smp_mflags} -k check
74 74
 %{_datadir}/man/man3/*
75 75
 
76 76
 %changelog
77
+*   Mon Jun 20 2022 Shivani Agarwal <shivania2@vmware.com> 4.4.0-1
78
+-   Fix CVE-2022-1622
77 79
 *   Mon May 16 2022 Shivani Agarwal <shivania2@vmware.com> 4.3.0-2
78 80
 -   Fix CVE-2022-22844, CVE-2022-0865, CVE-2022-0924, CVE-2022-0908, CVE-2022-0909, CVE-2022-0907, CVE-2022-0891
79 81
 *   Sat Apr 24 2021 Gerrit Photon <photon-checkins@vmware.com> 4.3.0-1
... ...
@@ -1,14 +1,14 @@
1 1
 Summary:	Library to encode and decode webP format images
2 2
 Name:		libwebp
3 3
 Version:	1.2.0
4
-Release:	1%{?dist}
4
+Release:	2%{?dist}
5 5
 License:	BSD
6 6
 URL:		http://webmproject.org/
7 7
 Group:		System Environment/Libraries
8 8
 Vendor:		VMware, Inc.
9 9
 Distribution:	Photon
10 10
 Source0:        https://github.com/webmproject/%{name}/archive/%{name}-%{version}.tar.gz
11
-%define sha1 libwebp=54383895bd18783c7af8517620252a712258b22c
11
+%define sha512  libwebp=177a4876035c300931ff3628a4ef6e2e7eb9372c126091f17ed0601c466b479e378d52cb593588df2844e1125395f50fc89a30c2908f2cc511b2e97c11a62968
12 12
 BuildRequires:	libjpeg-turbo-devel
13 13
 BuildRequires:	libtiff-devel
14 14
 BuildRequires:	libpng-devel
... ...
@@ -25,7 +25,7 @@ Requires:	%{name} = %{version}-%{release}
25 25
 It contains the libraries and header files to create applications
26 26
 
27 27
 %prep
28
-%setup -q
28
+%autosetup
29 29
 %build
30 30
 ./autogen.sh
31 31
 
... ...
@@ -39,7 +39,7 @@ It contains the libraries and header files to create applications
39 39
 make %{?_smp_mflags}
40 40
 
41 41
 %install
42
-make DESTDIR=%{buildroot} install
42
+make %{?_smp_mflags} DESTDIR=%{buildroot} install
43 43
 find %{buildroot} -name '*.la' -delete
44 44
 
45 45
 %post
... ...
@@ -61,6 +61,8 @@ find %{buildroot} -name '*.la' -delete
61 61
 %{_libdir}/pkgconfig/*.pc
62 62
 
63 63
 %changelog
64
+* 	Mon Jun 20 2022 Shivani Agarwal <shivania2@vmware.com>  1.2.0-2
65
+- 	Version bump up to use libtiff 4.4
64 66
 *       Thu Apr 29 2021 Gerrit Photon <photon-checkins@vmware.com> 1.2.0-1
65 67
 -       Automatic Version Bump
66 68
 *       Wed Jul 08 2020 Gerrit Photon <photon-checkins@vmware.com> 1.1.0-1