unzip-6.0-close.patch 6.1 KB

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