~ubuntu-branches/ubuntu/vivid/libzip/vivid

« back to all changes in this revision

Viewing changes to debian/patches/fix_broken_decrypt.patch

  • Committer: Package Import Robot
  • Author(s): Luk Claes
  • Date: 2012-07-07 02:03:46 UTC
  • Revision ID: package-import@ubuntu.com-20120707020346-diiem7sc5afkgpn2
Tags: 0.10.1-1.1
* Non-maintainer upload.
* Re-enable tests
* Fix broken decrypt on amd64 (Closes: 665225).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Index: libzip-0.10.1/lib/zip_source_pkware.c
 
2
===================================================================
 
3
--- libzip-0.10.1.orig/lib/zip_source_pkware.c  2012-03-15 09:27:50.000000000 +0000
 
4
+++ libzip-0.10.1/lib/zip_source_pkware.c       2012-07-07 02:03:29.000000000 +0000
 
5
@@ -49,10 +49,6 @@
 
6
 #define KEY1           591751049
 
7
 #define KEY2           878082192
 
8
 
 
9
-static const uLongf *crc = NULL;
 
10
-
 
11
-#define CRC32(c, b) (crc[((c) ^ (b)) & 0xff] ^ ((c) >> 8))
 
12
-
 
13
 
 
14
 
 
15
 static void decrypt(struct trad_pkware *, zip_uint8_t *,
 
16
@@ -80,9 +76,6 @@
 
17
        return NULL;
 
18
     }
 
19
 
 
20
-    if (crc == NULL)
 
21
-       crc = get_crc_table();
 
22
-
 
23
     if ((ctx=(struct trad_pkware *)malloc(sizeof(*ctx))) == NULL) {
 
24
        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
 
25
        return NULL;
 
26
@@ -128,10 +121,10 @@
 
27
            out[i] = b;
 
28
 
 
29
        /* update keys */
 
30
-       ctx->key[0] = CRC32(ctx->key[0], b);
 
31
+       ctx->key[0] = crc32(ctx->key[0] ^ 0xffffffffUL, &b, 1) ^ 0xffffffffUL;
 
32
        ctx->key[1] = (ctx->key[1] + (ctx->key[0] & 0xff)) * 134775813 + 1;
 
33
        b = ctx->key[1] >> 24;
 
34
-       ctx->key[2] = CRC32(ctx->key[2], b);
 
35
+       ctx->key[2] = crc32(ctx->key[2] ^ 0xffffffffUL, &b, 1) ^ 0xffffffffUL;
 
36
     }
 
37
 }
 
38