~ubuntu-branches/ubuntu/vivid/gzip/vivid

« back to all changes in this revision

Viewing changes to debian/patches/zeroify-buffers.diff

  • Committer: Steve Langasek
  • Date: 2012-05-02 21:43:58 UTC
  • mfrom: (4.1.7 sid)
  • Revision ID: steve.langasek@canonical.com-20120502214358-rqnb1qrcqh7l42og
Merge version 1.4-5 from Debian unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Description: clear gzip buffers between files
2
 
 When compressing multiple files on the commandline, empty the buffers in
3
 
 between each file to guard against small permutations in the resulting
4
 
 compressed files.
5
 
Author: Cyril Brulebois <kibi@debian.org>
6
 
Bug-Debian: http://bugs.debian.org/647522
7
 
Bug-Ubuntu: https://bugs.launchpad.net/bugs/871083
8
 
 
9
 
Index: trunk/gzip.c
10
 
===================================================================
11
 
--- trunk.orig/gzip.c
12
 
+++ trunk/gzip.c
13
 
@@ -561,6 +561,19 @@
14
 
            SET_BINARY_MODE(fileno(stdout));
15
 
        }
16
 
         while (optind < argc) {
17
 
+
18
 
+           /* Make sure buffers are reset to 0 to ensure reproducibility when handling several files */
19
 
+           ZEROIFY(uch, inbuf,  INBUFSIZ +INBUF_EXTRA);
20
 
+           ZEROIFY(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA);
21
 
+           ZEROIFY(ush, d_buf,  DIST_BUFSIZE);
22
 
+           ZEROIFY(uch, window, 2L*WSIZE);
23
 
+#ifndef MAXSEG_64K
24
 
+           ZEROIFY(ush, tab_prefix, 1L<<BITS);
25
 
+#else
26
 
+           ZEROIFY(ush, tab_prefix0, 1L<<(BITS-1));
27
 
+           ZEROIFY(ush, tab_prefix1, 1L<<(BITS-1));
28
 
+#endif
29
 
+
30
 
            treat_file(argv[optind++]);
31
 
        }
32
 
     } else {  /* Standard input */
33
 
Index: trunk/gzip.h
34
 
===================================================================
35
 
--- trunk.orig/gzip.h
36
 
+++ trunk/gzip.h
37
 
@@ -119,11 +119,13 @@
38
 
       array = (type*)fcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
39
 
       if (!array) xalloc_die (); \
40
 
    }
41
 
+#  define ZEROIFY(type, array, size) memset(array, 0, (size_t)(((size)+1L)/2)*2*sizeof(type))
42
 
 #  define FREE(array) {if (array != NULL) fcfree(array), array=NULL;}
43
 
 #else
44
 
 #  define EXTERN(type, array)  extern type array[]
45
 
 #  define DECLARE(type, array, size)  type array[size]
46
 
 #  define ALLOC(type, array, size)
47
 
+#  define ZEROIFY(type, array, size) { for (int i=0; i<size; i++) { array[i] = 0; } }
48
 
 #  define FREE(array)
49
 
 #endif
50