~ubuntu-branches/ubuntu/raring/sudo/raring

« back to all changes in this revision

Viewing changes to zlib/crc32.c

  • Committer: Package Import Robot
  • Author(s): Tyler Hicks
  • Date: 2012-07-16 14:01:42 UTC
  • mfrom: (1.3.22 sid)
  • Revision ID: package-import@ubuntu.com-20120716140142-b0tgau0k6nid4mrf
Tags: 1.8.5p2-1ubuntu1
* Merge from debian/testing (LP: #1024154), remaining changes:
  - debian/patches/keep_home_by_default.patch:
    + Set HOME in initial_keepenv_table.
  - debian/rules:
    + compile with --without-lecture --with-tty-tickets (Ubuntu specific)
    + install man/man8/sudo_root.8 in both flavours (Ubuntu specific)
    + install apport hooks
    + The ubuntu-sudo-as-admin-successful.patch was taken upstream by
      Debian however it requires a --enable-admin-flag configure flag to
      actually enable it in both flavours.
  - debian/control:
    + Mark Debian Vcs-* as XS-Debian-Vcs-*
    + update debian/control
  - debian/sudoers:
    + grant admin group sudo access
  - debian/source_sudo.py, debian/sudo-ldap.dirs, debian/sudo.dirs:
    + add usr/share/apport/package-hooks
  - debian/sudo.pam:
    + Use pam_env to read /etc/environment and /etc/default/locale
      environment files. Reading ~/.pam_environment is not permitted due to
      security reasons.
* Dropped changes:
  - debian/patches/lp927828-fix-abort-in-pam-modules-when-timestamp-valid.patch
    + Fixed upstream in 1.8.5
  - debian/patches/CVE-2012-2337.patch:
    + Fixed upstream in 1.8.4p5
  - debian/patches/pam_env_merge.patch:
    + Feature released upstream in 1.8.5
  - debian/{sudo,sudo-ldap}.{preinst,postinst,postrm}:
    + Drop Ubuntu-specific sudoers file migration code because the only
      upgrade path to quantal is from precise. All necessary sudoers file
      migration will have already been done by the time this version of the
      sudo package is installed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* crc32.c -- compute the CRC-32 of a data stream
2
 
 * Copyright (C) 1995-2006, 2010 Mark Adler
 
2
 * Copyright (C) 1995-2006, 2010, 2011 Mark Adler
3
3
 * For conditions of distribution and use, see copyright notice in zlib.h
4
4
 *
5
5
 * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
17
17
  of the crc tables.  Therefore, if you #define DYNAMIC_CRC_TABLE, you should
18
18
  first call get_crc_table() to initialize the tables before allowing more than
19
19
  one thread to use crc32().
 
20
 
 
21
  DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.
20
22
 */
21
23
 
22
24
#ifdef MAKECRCH
53
55
 
54
56
/* Definitions for doing the crc four data bytes at a time. */
55
57
#ifdef BYFOUR
 
58
   typedef u4 crc_table_t;
56
59
#  define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
57
60
                (((w)&0xff00)<<8)+(((w)&0xff)<<24))
58
61
   local unsigned long crc32_little OF((unsigned long,
61
64
                        const unsigned char FAR *, unsigned));
62
65
#  define TBLS 8
63
66
#else
 
67
   typedef unsigned long crc_table_t;
64
68
#  define TBLS 1
65
69
#endif /* BYFOUR */
66
70
 
68
72
local unsigned long gf2_matrix_times OF((unsigned long *mat,
69
73
                                         unsigned long vec));
70
74
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
71
 
local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2);
 
75
local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));
72
76
 
73
77
 
74
78
#ifdef DYNAMIC_CRC_TABLE
75
79
 
76
80
local volatile int crc_table_empty = 1;
77
 
local unsigned long FAR crc_table[TBLS][256];
 
81
local crc_table_t FAR crc_table[TBLS][256];
78
82
local void make_crc_table OF((void));
79
83
#ifdef MAKECRCH
80
 
   local void write_table OF((FILE *, const unsigned long FAR *));
 
84
   local void write_table OF((FILE *, const crc_table_t FAR *));
81
85
#endif /* MAKECRCH */
82
86
/*
83
87
  Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
107
111
*/
108
112
local void make_crc_table()
109
113
{
110
 
    unsigned long c;
 
114
    crc_table_t c;
111
115
    int n, k;
112
 
    unsigned long poly;                 /* polynomial exclusive-or pattern */
 
116
    crc_table_t poly;                   /* polynomial exclusive-or pattern */
113
117
    /* terms of polynomial defining this crc (except x^32): */
114
118
    static volatile int first = 1;      /* flag to limit concurrent making */
115
119
    static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
121
125
        first = 0;
122
126
 
123
127
        /* make exclusive-or pattern from polynomial (0xedb88320UL) */
124
 
        poly = 0UL;
125
 
        for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
126
 
            poly |= 1UL << (31 - p[n]);
 
128
        poly = 0;
 
129
        for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)
 
130
            poly |= (crc_table_t)1 << (31 - p[n]);
127
131
 
128
132
        /* generate a crc for every 8-bit value */
129
133
        for (n = 0; n < 256; n++) {
130
 
            c = (unsigned long)n;
 
134
            c = (crc_table_t)n;
131
135
            for (k = 0; k < 8; k++)
132
136
                c = c & 1 ? poly ^ (c >> 1) : c >> 1;
133
137
            crc_table[0][n] = c;
164
168
        if (out == NULL) return;
165
169
        fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
166
170
        fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
167
 
        fprintf(out, "local const unsigned long FAR ");
 
171
        fprintf(out, "local const crc_table_t FAR ");
168
172
        fprintf(out, "crc_table[TBLS][256] =\n{\n  {\n");
169
173
        write_table(out, crc_table[0]);
170
174
#  ifdef BYFOUR
184
188
#ifdef MAKECRCH
185
189
local void write_table(out, table)
186
190
    FILE *out;
187
 
    const unsigned long FAR *table;
 
191
    const crc_table_t FAR *table;
188
192
{
189
193
    int n;
190
194
 
191
195
    for (n = 0; n < 256; n++)
192
 
        fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : "    ", table[n],
 
196
        fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : "    ",
 
197
                (unsigned long)(table[n]),
193
198
                n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
194
199
}
195
200
#endif /* MAKECRCH */
210
215
    if (crc_table_empty)
211
216
        make_crc_table();
212
217
#endif /* DYNAMIC_CRC_TABLE */
213
 
    return (const unsigned long FAR *)crc_table;
 
218
    return (const unsigned long FAR *)(void FAR *)crc_table;
214
219
}
215
220
 
216
221
/* ========================================================================= */