| 1 | diff -up unzip60/extract.c.close unzip60/extract.c
|
| 2 | |
| 3 | |
| 4 | @@ -1924,24 +1924,21 @@ static int extract_or_test_member(__G)
|
| 5 |
|
| 6 | #ifdef VMS /* VMS: required even for stdout! (final flush) */
|
| 7 | if (!uO.tflag) /* don't close NULL file */
|
| 8 | - close_outfile(__G);
|
| 9 | + error = close_outfile(__G);
|
| 10 | #else
|
| 11 | #ifdef DLL
|
| 12 | if (!uO.tflag && (!uO.cflag || G.redirect_data)) {
|
| 13 | if (G.redirect_data)
|
| 14 | FINISH_REDIRECT();
|
| 15 | else
|
| 16 | - close_outfile(__G);
|
| 17 | + error = close_outfile(__G);
|
| 18 | }
|
| 19 | #else
|
| 20 | if (!uO.tflag && !uO.cflag) /* don't close NULL file or stdout */
|
| 21 | - close_outfile(__G);
|
| 22 | + error = close_outfile(__G);
|
| 23 | #endif
|
| 24 | #endif /* VMS */
|
| 25 |
|
| 26 | - /* GRR: CONVERT close_outfile() TO NON-VOID: CHECK FOR ERRORS! */
|
| 27 | -
|
| 28 | -
|
| 29 | if (G.disk_full) { /* set by flush() */
|
| 30 | if (G.disk_full > 1) {
|
| 31 | #if (defined(DELETE_IF_FULL) && defined(HAVE_UNLINK))
|
| 32 | diff -up unzip60/unix/unix.c.close unzip60/unix/unix.c
|
| 33 | |
| 34 | |
| 35 | @@ -1096,10 +1096,41 @@ static int get_extattribs(__G__ pzt, z_u
|
| 36 | #ifndef MTS
|
| 37 |
|
| 38 | /****************************/
|
| 39 | +/* Function CloseError() */
|
| 40 | +/***************************/
|
| 41 | +
|
| 42 | +int CloseError(__G)
|
| 43 | + __GDEF
|
| 44 | +{
|
| 45 | + int errval = PK_OK;
|
| 46 | +
|
| 47 | + if (fclose(G.outfile) < 0) {
|
| 48 | + switch (errno) {
|
| 49 | + case ENOSPC:
|
| 50 | + /* Do we need this on fileio.c? */
|
| 51 | + Info(slide, 0x4a1, ((char *)slide, "%s: write error (disk full?). Continue? (y/n/^C) ",
|
| 52 | + FnFilter1(G.filename)));
|
| 53 | + fgets(G.answerbuf, 9, stdin);
|
| 54 | + if (*G.answerbuf == 'y') /* stop writing to this file */
|
| 55 | + G.disk_full = 1; /* pass to next */
|
| 56 | + else
|
| 57 | + G.disk_full = 2; /* no: exit program */
|
| 58 | +
|
| 59 | + errval = PK_DISK;
|
| 60 | + break;
|
| 61 | +
|
| 62 | + default:
|
| 63 | + errval = PK_WARN;
|
| 64 | + }
|
| 65 | + }
|
| 66 | + return errval;
|
| 67 | +} /* End of CloseError() */
|
| 68 | +
|
| 69 | +/****************************/
|
| 70 | /* Function close_outfile() */
|
| 71 | /****************************/
|
| 72 |
|
| 73 | -void close_outfile(__G) /* GRR: change to return PK-style warning level */
|
| 74 | +int close_outfile(__G)
|
| 75 | __GDEF
|
| 76 | {
|
| 77 | union {
|
| 78 | @@ -1108,6 +1139,7 @@ void close_outfile(__G) /* GRR: chang
|
| 79 | } zt;
|
| 80 | ulg z_uidgid[2];
|
| 81 | int have_uidgid_flg;
|
| 82 | + int errval = PK_OK;
|
| 83 |
|
| 84 | have_uidgid_flg = get_extattribs(__G__ &(zt.t3), z_uidgid);
|
| 85 |
|
| 86 | @@ -1141,16 +1173,16 @@ void close_outfile(__G) /* GRR: chang
|
| 87 | Info(slide, 0x201, ((char *)slide,
|
| 88 | "warning: symbolic link (%s) failed: mem alloc overflow\n",
|
| 89 | FnFilter1(G.filename)));
|
| 90 | - fclose(G.outfile);
|
| 91 | - return;
|
| 92 | + errval = CloseError(G.outfile, G.filename);
|
| 93 | + return errval ? errval : PK_WARN;
|
| 94 | }
|
| 95 |
|
| 96 | if ((slnk_entry = (slinkentry *)malloc(slnk_entrysize)) == NULL) {
|
| 97 | Info(slide, 0x201, ((char *)slide,
|
| 98 | "warning: symbolic link (%s) failed: no mem\n",
|
| 99 | FnFilter1(G.filename)));
|
| 100 | - fclose(G.outfile);
|
| 101 | - return;
|
| 102 | + errval = CloseError(G.outfile, G.filename);
|
| 103 | + return errval ? errval : PK_WARN;
|
| 104 | }
|
| 105 | slnk_entry->next = NULL;
|
| 106 | slnk_entry->targetlen = ucsize;
|
| 107 | @@ -1174,10 +1206,10 @@ void close_outfile(__G) /* GRR: chang
|
| 108 | "warning: symbolic link (%s) failed\n",
|
| 109 | FnFilter1(G.filename)));
|
| 110 | free(slnk_entry);
|
| 111 | - fclose(G.outfile);
|
| 112 | - return;
|
| 113 | + errval = CloseError(G.outfile, G.filename);
|
| 114 | + return errval ? errval : PK_WARN;
|
| 115 | }
|
| 116 | - fclose(G.outfile); /* close "link" file for good... */
|
| 117 | + errval = CloseError(G.outfile, G.filename); /* close "link" file for good... */
|
| 118 | slnk_entry->target[ucsize] = '\0';
|
| 119 | if (QCOND2)
|
| 120 | Info(slide, 0, ((char *)slide, "-> %s ",
|
| 121 | @@ -1188,7 +1220,7 @@ void close_outfile(__G) /* GRR: chang
|
| 122 | else
|
| 123 | G.slink_head = slnk_entry;
|
| 124 | G.slink_last = slnk_entry;
|
| 125 | - return;
|
| 126 | + return errval;
|
| 127 | }
|
| 128 | #endif /* SYMLINKS */
|
| 129 |
|
| 130 | @@ -1201,7 +1233,7 @@ void close_outfile(__G) /* GRR: chang
|
| 131 | #endif
|
| 132 |
|
| 133 | #if (defined(NO_FCHOWN))
|
| 134 | - fclose(G.outfile);
|
| 135 | + errval = CloseError(G.outfile, G.filename);
|
| 136 | #endif
|
| 137 |
|
| 138 | /* if -X option was specified and we have UID/GID info, restore it */
|
| 139 | @@ -1227,7 +1259,7 @@ void close_outfile(__G) /* GRR: chang
|
| 140 | }
|
| 141 |
|
| 142 | #if (!defined(NO_FCHOWN) && defined(NO_FCHMOD))
|
| 143 | - fclose(G.outfile);
|
| 144 | + errval = CloseError(G.outfile, G.filename);
|
| 145 | #endif
|
| 146 |
|
| 147 | #if (!defined(NO_FCHOWN) && !defined(NO_FCHMOD))
|
| 148 | @@ -1239,7 +1271,7 @@ void close_outfile(__G) /* GRR: chang
|
| 149 | if (fchmod(fileno(G.outfile), filtattr(__G__ G.pInfo->file_attr)))
|
| 150 | perror("fchmod (file attributes) error");
|
| 151 |
|
| 152 | - fclose(G.outfile);
|
| 153 | + errval = CloseError(G.outfile, G.filename);
|
| 154 | #endif /* !NO_FCHOWN && !NO_FCHMOD */
|
| 155 |
|
| 156 | /* skip restoring time stamps on user's request */
|
| 157 | @@ -1267,6 +1299,7 @@ void close_outfile(__G) /* GRR: chang
|
| 158 | #endif
|
| 159 | #endif /* NO_FCHOWN || NO_FCHMOD */
|
| 160 |
|
| 161 | + return errval;
|
| 162 | } /* end function close_outfile() */
|
| 163 |
|
| 164 | #endif /* !MTS */
|
| 165 | diff -up unzip60/unzpriv.h.close unzip60/unzpriv.h
|
| 166 | |
| 167 | |
| 168 | @@ -2604,7 +2604,7 @@ char *GetLoadPath OF((__GPRO));
|
| 169 | int SetFileSize OF((FILE *file, zusz_t filesize)); /* local */
|
| 170 | #endif
|
| 171 | #ifndef MTS /* macro in MTS */
|
| 172 | - void close_outfile OF((__GPRO)); /* local */
|
| 173 | + int close_outfile OF((__GPRO)); /* local */
|
| 174 | #endif
|
| 175 | #ifdef SET_SYMLINK_ATTRIBS
|
| 176 | int set_symlnk_attribs OF((__GPRO__ slinkentry *slnk_entry)); /* local */
|