all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 755e188c59b986ce4bf1b8d27b340bfffbcb17ed 3121 bytes (raw)
name: gnu/packages/patches/graphicsmagick-CVE-2017-14042.patch 	 # note: path name is non-authoritative(*)

 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
 
http://openwall.com/lists/oss-security/2017/08/28/5
http://hg.code.sf.net/p/graphicsmagick/code/rev/3bbf7a13643d

some changes were made to make the patch apply

# HG changeset patch
# User Bob Friesenhahn <bfriesen@GraphicsMagick.org>
# Date 1503268616 18000
# Node ID 3bbf7a13643df3be76b0e19088a6cc632eea2072
# Parent  83a5b946180835f260bcb91e3d06327a8e2577e3
PNM: For binary formats, verify sufficient backing file data before memory request.

diff -r 83a5b9461808 -r 3bbf7a13643d coders/pnm.c
--- a/coders/pnm.c	Sun Aug 20 17:31:35 2017 -0500
+++ b/coders/pnm.c	Sun Aug 20 17:36:56 2017 -0500
@@ -569,7 +569,7 @@
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Colors: %u",
                                 image->colors);
         }
-      number_pixels=image->columns*image->rows;
+      number_pixels=MagickArraySize(image->columns,image->rows);
       if (number_pixels == 0)
         ThrowReaderException(CorruptImageError,NegativeOrZeroImageSize,image);
       if (image->storage_class == PseudoClass)
@@ -858,14 +858,14 @@
 		if (1 == bits_per_sample)
 		  {
 		    /* PBM */
-		    bytes_per_row=((image->columns+7) >> 3);
+		    bytes_per_row=((image->columns+7U) >> 3);
 		    import_options.grayscale_miniswhite=MagickTrue;
 		    quantum_type=GrayQuantum;
 		  }
 		else
 		  {
 		    /* PGM & XV_332 */
-		    bytes_per_row=((bits_per_sample+7)/8)*image->columns;
+		    bytes_per_row=MagickArraySize(((bits_per_sample+7U)/8U),image->columns);
 		    if (XV_332_Format == format)
 		      {
 			quantum_type=IndexQuantum;
@@ -878,7 +878,8 @@
 	      }
 	    else
 	      {
-		bytes_per_row=(((bits_per_sample+7)/8)*samples_per_pixel)*image->columns;
+		bytes_per_row=MagickArraySize((((bits_per_sample+7)/8)*samples_per_pixel),
+                                              image->columns);
 		if (3 == samples_per_pixel)
 		  {
 		    /* PPM */
@@ -915,6 +916,28 @@
 		    is_monochrome=MagickFalse;
 		  }
 	      }
+
+            /* Validate file size before allocating memory */
+            if (BlobIsSeekable(image))
+              {
+                const magick_off_t file_size = GetBlobSize(image);
+                const magick_off_t current_offset = TellBlob(image);
+                if ((file_size > 0) &&
+                    (current_offset > 0) &&
+                    (file_size > current_offset))
+                  {
+                    const magick_off_t remaining = file_size-current_offset;
+                    const magick_off_t needed = (magick_off_t) image->rows *
+                      (magick_off_t) bytes_per_row;
+                    if ((remaining < (magick_off_t) bytes_per_row) ||
+                        (remaining < needed))
+                      {
+                        ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
+                                       image->filename);
+                        break;
+                      }
+                  }
+              }
         
             scanline_set=AllocateThreadViewDataArray(image,exception,bytes_per_row,1);
             if (scanline_set == (ThreadViewDataSet *) NULL)

debug log:

solving 755e188c5 ...
found 755e188c5 in https://yhetil.org/guix/20170909134308.29996-1-kkebreau@posteo.net/

applying [1/1] https://yhetil.org/guix/20170909134308.29996-1-kkebreau@posteo.net/
diff --git a/gnu/packages/patches/graphicsmagick-CVE-2017-14042.patch b/gnu/packages/patches/graphicsmagick-CVE-2017-14042.patch
new file mode 100644
index 000000000..755e188c5

1:32: space before tab in indent.
 		if (1 == bits_per_sample)
1:33: space before tab in indent.
 		  {
1:34: space before tab in indent.
 		    /* PBM */
1:37: space before tab in indent.
 		    import_options.grayscale_miniswhite=MagickTrue;
1:38: space before tab in indent.
 		    quantum_type=GrayQuantum;
Checking patch gnu/packages/patches/graphicsmagick-CVE-2017-14042.patch...
Applied patch gnu/packages/patches/graphicsmagick-CVE-2017-14042.patch cleanly.
warning: squelched 17 whitespace errors
warning: 22 lines add whitespace errors.

index at:
100644 755e188c59b986ce4bf1b8d27b340bfffbcb17ed	gnu/packages/patches/graphicsmagick-CVE-2017-14042.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.