summaryrefslogtreecommitdiff
path: root/Build/source/libs/zziplib/TLpatches/patch-01-binary
blob: 6b5f4f77f76fce08fb0546a11fe5412fbfa128a4 (plain)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
diff -ur zziplib-0.13.66.orig/bins/unzip-mem.c zziplib-0.13.66/bins/unzip-mem.c
--- zziplib-0.13.66.orig/bins/unzip-mem.c	Mon Apr 24 08:46:28 2017
+++ zziplib-0.13.66/bins/unzip-mem.c	Tue Jun 20 09:49:08 2017
@@ -100,7 +100,7 @@
 static void zzip_mem_entry_make(ZZIP_MEM_DISK* disk, 
 				ZZIP_MEM_ENTRY* entry)
 {
-    FILE* file = fopen (entry->zz_name, "w");
+    FILE* file = fopen (entry->zz_name, "wb");
     if (file) { zzip_mem_entry_pipe (disk, entry, file); fclose (file); }
     perror (entry->zz_name);
     if (status < EXIT_WARNINGS) status = EXIT_WARNINGS;
diff -ur zziplib-0.13.66.orig/bins/unzzipcat-big.c zziplib-0.13.66/bins/unzzipcat-big.c
--- zziplib-0.13.66.orig/bins/unzzipcat-big.c	Mon Apr 24 08:46:28 2017
+++ zziplib-0.13.66/bins/unzzipcat-big.c	Thu Jun 22 07:38:57 2017
@@ -62,6 +62,21 @@
     }
 }
 
+#if !defined(ZZIP_HAVE_STRNDUP)
+static char *
+strndup(char *p, size_t maxlen)
+{
+    char *r;
+    if (!p)
+	return NULL;
+    r = malloc(maxlen + 1);
+    if (!r)
+	return NULL;
+    strncpy(r, p, maxlen);
+    r[maxlen] = '\0';
+    return r;
+}
+#endif
 
 static FILE* create_fopen(char* name, char* mode, int subdirs)
 {
@@ -83,7 +98,7 @@
     int argn;
     FILE* disk;
 
-    disk = fopen (argv[1], "r");
+    disk = fopen (argv[1], "rb");
     if (! disk) {
 	perror(argv[1]);
 	return -1;
@@ -96,7 +111,7 @@
 	{
 	    char* name = zzip_entry_strdup_name (entry);
 	    FILE* out = stdout;
-	    if (extract) out = create_fopen(name, "w", 1);
+	    if (extract) out = create_fopen(name, "wb", 1);
 	    unzzip_cat_file (disk, name, out);
 	    if (extract) fclose(out);
 	    free (name);
@@ -125,7 +140,7 @@
 			   FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
 	    {
 	        FILE* out = stdout;
-	        if (extract) out = create_fopen(name, "w", 1);
+	        if (extract) out = create_fopen(name, "wb", 1);
 		unzzip_cat_file (disk, name, out);
 		if (extract) fclose(out);
 		break; /* match loop */
diff -ur zziplib-0.13.66.orig/bins/unzzipcat-mem.c zziplib-0.13.66/bins/unzzipcat-mem.c
--- zziplib-0.13.66.orig/bins/unzzipcat-mem.c	Mon Apr 24 08:46:28 2017
+++ zziplib-0.13.66/bins/unzzipcat-mem.c	Thu Jun 22 07:39:23 2017
@@ -57,6 +57,22 @@
     }
 }
 
+#if !defined(ZZIP_HAVE_STRNDUP)
+static char *
+strndup(char *p, size_t maxlen)
+{
+    char *r;
+    if (!p)
+	return NULL;
+    r = malloc(maxlen + 1);
+    if (!r)
+	return NULL;
+    strncpy(r, p, maxlen);
+    r[maxlen] = '\0';
+    return r;
+}
+#endif
+
 static FILE* create_fopen(char* name, char* mode, int subdirs)
 {
    if (subdirs)
@@ -97,7 +113,7 @@
 	{
 	    char* name = zzip_mem_entry_to_name (entry);
 	    FILE* out = stdout;
-	    if (extract) out = create_fopen(name, "w", 1);
+	    if (extract) out = create_fopen(name, "wb", 1);
 	    unzzip_mem_disk_cat_file (disk, name, out);
 	    if (extract) fclose(out);
 	}
@@ -125,7 +141,7 @@
 			   FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
 	    {
 	        FILE* out = stdout;
-	        if (extract) out = create_fopen(name, "w", 1);
+	        if (extract) out = create_fopen(name, "wb", 1);
 		unzzip_mem_disk_cat_file (disk, name, out);
 		if (extract) fclose(out);
 		break; /* match loop */
diff -ur zziplib-0.13.66.orig/bins/unzzipcat-mix.c zziplib-0.13.66/bins/unzzipcat-mix.c
--- zziplib-0.13.66.orig/bins/unzzipcat-mix.c	Mon Apr 24 08:46:28 2017
+++ zziplib-0.13.66/bins/unzzipcat-mix.c	Thu Jun 22 07:39:54 2017
@@ -30,7 +30,7 @@
 
 static void unzzip_cat_file(ZZIP_DIR* disk, char* name, FILE* out)
 {
-    ZZIP_FILE* file = zzip_fopen(name, "r");
+    ZZIP_FILE* file = zzip_fopen(name, "rb");
     if (file) 
     {
 	char buffer[1024]; int len;
@@ -43,6 +43,22 @@
     }
 }
 
+#if !defined(ZZIP_HAVE_STRNDUP)
+static char *
+strndup(char *p, size_t maxlen)
+{
+    char *r;
+    if (!p)
+	return NULL;
+    r = malloc(maxlen + 1);
+    if (!r)
+	return NULL;
+    strncpy(r, p, maxlen);
+    r[maxlen] = '\0';
+    return r;
+}
+#endif
+
 static FILE* create_fopen(char* name, char* mode, int subdirs)
 {
    if (subdirs)
@@ -82,7 +98,7 @@
 	{
 	    char* name = entry->d_name;
 	    FILE* out = stdout;
-	    if (extract) out = create_fopen(name, "w", 1);
+	    if (extract) out = create_fopen(name, "wb", 1);
 	    unzzip_cat_file (disk, name, out);
 	    if (extract) fclose(out);
 	}
@@ -108,7 +124,7 @@
 	             memcpy(mix_name, zip_name, zip_name_len);
 	             mix_name[zip_name_len] = '/';
 	             strcpy(mix_name + zip_name_len + 1, name);
-	             if (extract) out = create_fopen(name, "w", 1);
+	             if (extract) out = create_fopen(name, "wb", 1);
 		     fprintf(stderr, "%s %s -> %s\n", zip_name, name, mix_name);
 		     /* 'test1.zip' 'README' -> 'test1/README' */
 		     unzzip_cat_file (disk, mix_name, out);
diff -ur zziplib-0.13.66.orig/bins/unzzipcat-zip.c zziplib-0.13.66/bins/unzzipcat-zip.c
--- zziplib-0.13.66.orig/bins/unzzipcat-zip.c	Mon Apr 24 08:46:28 2017
+++ zziplib-0.13.66/bins/unzzipcat-zip.c	Thu Jun 22 07:40:29 2017
@@ -43,6 +43,22 @@
     }
 }
 
+#if !defined(ZZIP_HAVE_STRNDUP)
+static char *
+strndup(char *p, size_t maxlen)
+{
+    char *r;
+    if (!p)
+	return NULL;
+    r = malloc(maxlen + 1);
+    if (!r)
+	return NULL;
+    strncpy(r, p, maxlen);
+    r[maxlen] = '\0';
+    return r;
+}
+#endif
+
 static FILE* create_fopen(char* name, char* mode, int subdirs)
 {
    if (subdirs)
@@ -83,7 +99,7 @@
 	{
 	    char* name = entry.d_name;
 	    FILE* out = stdout;
-	    if (extract) out = create_fopen(name, "w", 1);
+	    if (extract) out = create_fopen(name, "wb", 1);
 	    unzzip_cat_file (disk, name, out);
 	    if (extract) fclose(out);
 	}
@@ -100,7 +116,7 @@
 			       FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
 	        {
 	             FILE* out = stdout;
-	             if (extract) out = create_fopen(name, "w", 1);
+	             if (extract) out = create_fopen(name, "wb", 1);
 		     unzzip_cat_file (disk, name, out);
 		     if (extract) fclose(out);
 		     break; /* match loop */
diff -ur zziplib-0.13.66.orig/bins/unzzipdir-big.c zziplib-0.13.66/bins/unzzipdir-big.c
--- zziplib-0.13.66.orig/bins/unzzipdir-big.c	Mon Apr 24 08:46:28 2017
+++ zziplib-0.13.66/bins/unzzipdir-big.c	Thu Jun 22 07:32:13 2017
@@ -35,7 +35,7 @@
     int argn;
     FILE* disk;
 
-    disk = fopen (argv[1], "r");
+    disk = fopen (argv[1], "rb");
     if (! disk) {
 	perror(argv[1]);
 	return -1;
diff -ur zziplib-0.13.66.orig/bins/unzzipshow.c zziplib-0.13.66/bins/unzzipshow.c
--- zziplib-0.13.66.orig/bins/unzzipshow.c	Mon Apr 24 08:46:28 2017
+++ zziplib-0.13.66/bins/unzzipshow.c	Thu Jun 22 07:32:44 2017
@@ -68,7 +68,7 @@
 	return 0;
     }
 
-    disk = fopen (argv[1], "r");
+    disk = fopen (argv[1], "rb");
     if (! disk) {
 	perror(argv[1]);
 	return -1;