4093b9f
diff -rupN libkml-1.3.0/src/kml/base/contrib/minizip/crypt.h libkml-1.3.0-new/src/kml/base/contrib/minizip/crypt.h
4093b9f
--- libkml-1.3.0/src/kml/base/contrib/minizip/crypt.h	1970-01-01 01:00:00.000000000 +0100
4093b9f
+++ libkml-1.3.0-new/src/kml/base/contrib/minizip/crypt.h	2018-06-19 13:59:43.300760312 +0200
4093b9f
@@ -0,0 +1,131 @@
4093b9f
+/* crypt.h -- base code for crypt/uncrypt ZIPfile
4093b9f
+
4093b9f
+
4093b9f
+   Version 1.01e, February 12th, 2005
4093b9f
+
4093b9f
+   Copyright (C) 1998-2005 Gilles Vollant
4093b9f
+
4093b9f
+   This code is a modified version of crypting code in Infozip distribution
4093b9f
+
4093b9f
+   The encryption/decryption parts of this source code (as opposed to the
4093b9f
+   non-echoing password parts) were originally written in Europe.  The
4093b9f
+   whole source package can be freely distributed, including from the USA.
4093b9f
+   (Prior to January 2000, re-export from the US was a violation of US law.)
4093b9f
+
4093b9f
+   This encryption code is a direct transcription of the algorithm from
4093b9f
+   Roger Schlafly, described by Phil Katz in the file appnote.txt.  This
4093b9f
+   file (appnote.txt) is distributed with the PKZIP program (even in the
4093b9f
+   version without encryption capabilities).
4093b9f
+
4093b9f
+   If you don't need crypting in your application, just define symbols
4093b9f
+   NOCRYPT and NOUNCRYPT.
4093b9f
+
4093b9f
+   This code support the "Traditional PKWARE Encryption".
4093b9f
+
4093b9f
+   The new AES encryption added on Zip format by Winzip (see the page
4093b9f
+   http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
4093b9f
+   Encryption is not supported.
4093b9f
+*/
4093b9f
+
4093b9f
+#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
4093b9f
+
4093b9f
+/***********************************************************************
4093b9f
+ * Return the next byte in the pseudo-random sequence
4093b9f
+ */
4093b9f
+static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
4093b9f
+{
4093b9f
+    unsigned temp;  /* POTENTIAL BUG:  temp*(temp^1) may overflow in an
4093b9f
+                     * unpredictable manner on 16-bit systems; not a problem
4093b9f
+                     * with any known compiler so far, though */
4093b9f
+
4093b9f
+    temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
4093b9f
+    return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
4093b9f
+}
4093b9f
+
4093b9f
+/***********************************************************************
4093b9f
+ * Update the encryption keys with the next byte of plain text
4093b9f
+ */
4093b9f
+static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
4093b9f
+{
4093b9f
+    (*(pkeys+0)) = CRC32((*(pkeys+0)), c);
4093b9f
+    (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
4093b9f
+    (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
4093b9f
+    {
4093b9f
+      register int keyshift = (int)((*(pkeys+1)) >> 24);
4093b9f
+      (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
4093b9f
+    }
4093b9f
+    return c;
4093b9f
+}
4093b9f
+
4093b9f
+
4093b9f
+/***********************************************************************
4093b9f
+ * Initialize the encryption keys and the random header according to
4093b9f
+ * the given password.
4093b9f
+ */
4093b9f
+static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab)
4093b9f
+{
4093b9f
+    *(pkeys+0) = 305419896L;
4093b9f
+    *(pkeys+1) = 591751049L;
4093b9f
+    *(pkeys+2) = 878082192L;
4093b9f
+    while (*passwd != '\0') {
4093b9f
+        update_keys(pkeys,pcrc_32_tab,(int)*passwd);
4093b9f
+        passwd++;
4093b9f
+    }
4093b9f
+}
4093b9f
+
4093b9f
+#define zdecode(pkeys,pcrc_32_tab,c) \
4093b9f
+    (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
4093b9f
+
4093b9f
+#define zencode(pkeys,pcrc_32_tab,c,t) \
4093b9f
+    (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
4093b9f
+
4093b9f
+#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
4093b9f
+
4093b9f
+#define RAND_HEAD_LEN  12
4093b9f
+   /* "last resort" source for second part of crypt seed pattern */
4093b9f
+#  ifndef ZCR_SEED2
4093b9f
+#    define ZCR_SEED2 3141592654UL     /* use PI as default pattern */
4093b9f
+#  endif
4093b9f
+
4093b9f
+static int crypthead(const char* passwd,      /* password string */
4093b9f
+                     unsigned char* buf,      /* where to write header */
4093b9f
+                     int bufSize,
4093b9f
+                     unsigned long* pkeys,
4093b9f
+                     const z_crc_t* pcrc_32_tab,
4093b9f
+                     unsigned long crcForCrypting)
4093b9f
+{
4093b9f
+    int n;                       /* index in random header */
4093b9f
+    int t;                       /* temporary */
4093b9f
+    int c;                       /* random byte */
4093b9f
+    unsigned char header[RAND_HEAD_LEN-2]; /* random header */
4093b9f
+    static unsigned calls = 0;   /* ensure different random header each time */
4093b9f
+
4093b9f
+    if (bufSize
4093b9f
+      return 0;
4093b9f
+
4093b9f
+    /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
4093b9f
+     * output of rand() to get less predictability, since rand() is
4093b9f
+     * often poorly implemented.
4093b9f
+     */
4093b9f
+    if (++calls == 1)
4093b9f
+    {
4093b9f
+        srand((unsigned)(time(NULL) ^ ZCR_SEED2));
4093b9f
+    }
4093b9f
+    init_keys(passwd, pkeys, pcrc_32_tab);
4093b9f
+    for (n = 0; n < RAND_HEAD_LEN-2; n++)
4093b9f
+    {
4093b9f
+        c = (rand() >> 7) & 0xff;
4093b9f
+        header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
4093b9f
+    }
4093b9f
+    /* Encrypt random header (last two bytes is high word of crc) */
4093b9f
+    init_keys(passwd, pkeys, pcrc_32_tab);
4093b9f
+    for (n = 0; n < RAND_HEAD_LEN-2; n++)
4093b9f
+    {
4093b9f
+        buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
4093b9f
+    }
4093b9f
+    buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
4093b9f
+    buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
4093b9f
+    return n;
4093b9f
+}
4093b9f
+
4093b9f
+#endif
4093b9f
diff -rupN libkml-1.3.0/src/kml/base/contrib/minizip/unzip.c libkml-1.3.0-new/src/kml/base/contrib/minizip/unzip.c
4093b9f
--- libkml-1.3.0/src/kml/base/contrib/minizip/unzip.c	2015-12-21 18:23:05.000000000 +0100
4093b9f
+++ libkml-1.3.0-new/src/kml/base/contrib/minizip/unzip.c	2018-06-19 14:00:07.633758966 +0200
4093b9f
@@ -180,7 +180,7 @@ void init_unz_s(unz_s* un)
4093b9f
 }
4093b9f
 
4093b9f
 #ifndef NOUNCRYPT
4093b9f
-#include <minizip/crypt.h>
4093b9f
+#include "crypt.h"
4093b9f
 #endif
4093b9f
 
4093b9f
 /* ===========================================================================