]> git.pld-linux.org Git - packages/libzip.git/blob - libzip-0.10-php-changes.patch
- add php changes patch
[packages/libzip.git] / libzip-0.10-php-changes.patch
1 diff -up libzip-0.10/lib/zip_close.c.php libzip-0.10/lib/zip_close.c
2 --- libzip-0.10/lib/zip_close.c.php     2011-07-20 11:27:34.081252871 -0400
3 +++ libzip-0.10/lib/zip_close.c 2011-07-20 11:30:50.176682999 -0400
4 @@ -337,6 +337,8 @@ zip_close(struct zip *za)
5      umask(mask);
6      chmod(za->zn, 0666&~mask);
7  #endif
8 +    if (za->ch_comment)
9 +        free(za->ch_comment);
10  
11      _zip_free(za);
12      free(temp);
13 @@ -602,13 +604,15 @@ _zip_create_temp_output(struct zip *za, 
14      char *temp;
15      int tfd;
16      FILE *tfp;
17 +
18 +    int len = strlen(za->zn) + 8;
19      
20 -    if ((temp=(char *)malloc(strlen(za->zn)+8)) == NULL) {
21 +    if ((temp=(char *)malloc(len)) == NULL) {
22         _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
23         return NULL;
24      }
25  
26 -    sprintf(temp, "%s.XXXXXX", za->zn);
27 +    snprintf(temp, len, "%s.XXXXXX", za->zn);
28  
29      if ((tfd=mkstemp(temp)) == -1) {
30         _zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno);
31 diff -up libzip-0.10/lib/zip_fclose.c.php libzip-0.10/lib/zip_fclose.c
32 --- libzip-0.10/lib/zip_fclose.c.php    2011-07-20 11:38:05.883077282 -0400
33 +++ libzip-0.10/lib/zip_fclose.c        2011-07-20 11:38:10.452025182 -0400
34 @@ -47,12 +47,14 @@ zip_fclose(struct zip_file *zf)
35      if (zf->src)
36         zip_source_free(zf->src);
37  
38 -    for (i=0; i<zf->za->nfile; i++) {
39 -       if (zf->za->file[i] == zf) {
40 -           zf->za->file[i] = zf->za->file[zf->za->nfile-1];
41 -           zf->za->nfile--;
42 -           break;
43 -       }
44 +    if (zf->za) {
45 +        for (i=0; i<zf->za->nfile; i++) {
46 +           if (zf->za->file[i] == zf) {
47 +               zf->za->file[i] = zf->za->file[zf->za->nfile-1];
48 +               zf->za->nfile--;
49 +               break;
50 +           }
51 +        }
52      }
53  
54      ret = 0;
55 diff -up libzip-0.10/lib/zip.h.php libzip-0.10/lib/zip.h
56 --- libzip-0.10/lib/zip.h.php   2011-07-20 11:39:40.732027472 -0400
57 +++ libzip-0.10/lib/zip.h       2011-07-20 11:40:28.626521627 -0400
58 @@ -59,7 +59,7 @@ extern "C" {
59  #define ZIP_CREATE           1
60  #define ZIP_EXCL             2
61  #define ZIP_CHECKCONS        4
62 -
63 +#define ZIP_OVERWRITE        8
64  
65  /* flags for zip_name_locate, zip_fopen, zip_stat, ... */
66  
67 diff -up libzip-0.10/lib/zipint.h.php libzip-0.10/lib/zipint.h
68 diff -up libzip-0.10/lib/zip_open.c.php libzip-0.10/lib/zip_open.c
69 --- libzip-0.10/lib/zip_open.c.php      2011-07-20 11:44:01.270451036 -0400
70 +++ libzip-0.10/lib/zip_open.c  2011-07-20 11:45:33.877629039 -0400
71 @@ -61,10 +61,16 @@ ZIP_EXTERN struct zip *
72  zip_open(const char *fn, int flags, int *zep)
73  {
74      FILE *fp;
75 +
76 +    if (flags & ZIP_OVERWRITE) {
77 +       return _zip_allocate_new(fn, zep);
78 +    }
79      
80      switch (_zip_file_exists(fn, flags, zep)) {
81      case -1:
82 -       return NULL;
83 +        if (!(flags & ZIP_OVERWRITE)) {
84 +            return NULL;
85 +        }
86      case 0:
87         return _zip_allocate_new(fn, zep);
88      default:
89 @@ -482,7 +488,7 @@ _zip_file_exists(const char *fn, int fla
90      }
91      
92      if (stat(fn, &st) != 0) {
93 -       if (flags & ZIP_CREATE)
94 +       if (flags & ZIP_CREATE || flags & ZIP_OVERWRITE)
95             return 0;
96         else {
97             set_error(zep, NULL, ZIP_ER_OPEN);
This page took 0.10839 seconds and 3 git commands to generate.