zipruby 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of zipruby might be problematic. Click here for more details.

Files changed (3) hide show
  1. data/ext/zip_crypt.c +11 -6
  2. data/ext/zipruby.h +1 -1
  3. metadata +2 -2
@@ -64,11 +64,11 @@ static int decrypt_header(unsigned long *keys, char *buffer, struct zip_dirent *
64
64
  }
65
65
 
66
66
  if (de->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) {
67
- return ((c & 0xff) == (de->crc >> 24)) ? 0 : -1;
68
- } else {
69
67
  unsigned short dostime, dosdate;
70
68
  _zip_u2d_time(de->last_mod, &dostime, &dosdate);
71
69
  return ((c & 0xff) == (dostime >> 8)) ? 0 : -1;
70
+ } else {
71
+ return ((c & 0xff) == (de->crc >> 24)) ? 0 : -1;
72
72
  }
73
73
  }
74
74
 
@@ -257,7 +257,9 @@ static int _zip_crypt(struct zip *za, const char *pwd, int pwdlen, int decrypt,
257
257
  }
258
258
 
259
259
  for (i = 0; i < za->nentry; i++) {
260
+ struct zip_dirent fde;
260
261
  int encrypted;
262
+ unsigned int comp_size;
261
263
 
262
264
  if (fseeko(za->zp, za->cdir->entry[i].offset, SEEK_SET) != 0) {
263
265
  _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
@@ -270,6 +272,9 @@ static int _zip_crypt(struct zip *za, const char *pwd, int pwdlen, int decrypt,
270
272
  break;
271
273
  }
272
274
 
275
+ memcpy(&fde, &de, sizeof(fde));
276
+ encrypted = de.bitflags & ZIP_GPBF_ENCRYPTED;
277
+
273
278
  if (de.bitflags & ZIP_GPBF_DATA_DESCRIPTOR) {
274
279
  de.crc = za->cdir->entry[i].crc;
275
280
  de.comp_size = za->cdir->entry[i].comp_size;
@@ -278,13 +283,13 @@ static int _zip_crypt(struct zip *za, const char *pwd, int pwdlen, int decrypt,
278
283
  }
279
284
 
280
285
  memcpy(cd->entry + i, za->cdir->entry + i, sizeof(cd->entry[i]));
286
+ comp_size = cd->entry[i].comp_size;
281
287
 
282
288
  if (cd->entry[i].bitflags & ZIP_GPBF_DATA_DESCRIPTOR) {
283
289
  cd->entry[i].bitflags &= ~ZIP_GPBF_DATA_DESCRIPTOR;
284
290
  }
285
291
 
286
292
  cd->entry[i].offset = ftello(out);
287
- encrypted = de.bitflags & ZIP_GPBF_ENCRYPTED;
288
293
 
289
294
  if (decrypt && encrypted) {
290
295
  de.comp_size -= ZIPENC_HEAD_LEN;
@@ -304,11 +309,11 @@ static int _zip_crypt(struct zip *za, const char *pwd, int pwdlen, int decrypt,
304
309
  }
305
310
 
306
311
  if (decrypt && encrypted) {
307
- error = (copy_decrypt(za->zp, cd->entry[i].comp_size, pwd, pwdlen, &de, out, &za->error, wrongpwd) < 0);
312
+ error = (copy_decrypt(za->zp, comp_size, pwd, pwdlen, &fde, out, &za->error, wrongpwd) < 0);
308
313
  } else if (!decrypt && !encrypted) {
309
- error = (copy_encrypt(za->zp, (cd->entry[i].comp_size - ZIPENC_HEAD_LEN), pwd, pwdlen, &de, out, &za->error) < 0);
314
+ error = (copy_encrypt(za->zp, comp_size, pwd, pwdlen, &fde, out, &za->error) < 0);
310
315
  } else {
311
- error = (copy_data(za->zp, cd->entry[i].comp_size, out, &za->error) < 0);
316
+ error = (copy_data(za->zp, comp_size, out, &za->error) < 0);
312
317
  }
313
318
 
314
319
  if (error) {
@@ -1,7 +1,7 @@
1
1
  #ifndef __ZIPRUBY_H__
2
2
  #define __ZIPRUBY_H__
3
3
 
4
- #define VERSION "0.2.2"
4
+ #define VERSION "0.2.3"
5
5
  #define ERRSTR_BUFSIZE 256
6
6
  #define DATA_BUFSIZE 8192
7
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zipruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - winebarrel
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-30 00:00:00 +09:00
12
+ date: 2008-05-01 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15