Browse code

zip fixes

git-svn: trunk@4228

aCaB authored on 2008/10/07 20:15:32
Showing 7 changed files
... ...
@@ -1,3 +1,8 @@
1
+Tue Oct  7 13:21:04 CEST 2008 (acab)
2
+------------------------------------
3
+  * libclamav/unzip.c: error path fixes, handle bzip2's deflate in a special manner - bb#1220
4
+  * test: add clam.bz2.zip
5
+
1 6
 Fri Oct  3 19:28:18 CEST 2008 (acab)
2 7
 ------------------------------------
3 8
   * clamav-milter/clamav-milter.c: properly close descriptors before
4 9
new file mode 100644
5 10
Binary files /dev/null and b/contrib/test/clam.bz2.zip differ
... ...
@@ -174,7 +174,8 @@ static int unz(uint8_t *src, uint32_t csize, uint32_t usize, uint16_t method, ui
174 174
 	if(cli_writen(of, obuf, sizeof(obuf)-(*avail_out)) != (int)(sizeof(obuf)-(*avail_out))) {
175 175
 	  cli_warnmsg("cli_unzip: falied to write %lu inflated bytes\n", sizeof(obuf)-(*avail_out));
176 176
 	  ret = CL_EIO;
177
-	  res=1;
177
+	  res = 100;
178
+	  break;
178 179
 	}
179 180
 	*next_out = obuf;
180 181
 	*avail_out = sizeof(obuf);
... ...
@@ -217,18 +218,17 @@ static int unz(uint8_t *src, uint32_t csize, uint32_t usize, uint16_t method, ui
217 217
 	if(cli_writen(of, obuf, sizeof(obuf)-strm.avail_out) != (int)(sizeof(obuf)-strm.avail_out)) {
218 218
 	  cli_warnmsg("cli_unzip: falied to write %lu bunzipped bytes\n", sizeof(obuf)-strm.avail_out);
219 219
 	  ret = CL_EIO;
220
-	  res=1;
220
+	  res = 100;
221
+	  break;
221 222
 	}
222 223
 	strm.next_out = obuf;
223 224
 	strm.avail_out = sizeof(obuf);
224
-	continue;
225
+	if (res == BZ_OK) continue; /* after returning BZ_STREAM_END once, decompress returns an error */
225 226
       }
226 227
       break;
227 228
     }
228 229
     BZ2_bzDecompressEnd(&strm);
229
-    if (res == BZ_STREAM_END) {
230
-      res=0;
231
-    }
230
+    if (res == BZ_STREAM_END) res=0;
232 231
     break;
233 232
   }
234 233
 #endif /* HAVE_BZLIB_H */
... ...
@@ -255,7 +255,8 @@ static int unz(uint8_t *src, uint32_t csize, uint32_t usize, uint16_t method, ui
255 255
 	if(cli_writen(of, obuf, sizeof(obuf)-strm.avail_out) != (int)(sizeof(obuf)-strm.avail_out)) {
256 256
 	  cli_warnmsg("cli_unzip: falied to write %lu exploded bytes\n", sizeof(obuf)-strm.avail_out);
257 257
 	  ret = CL_EIO;
258
-	  res=1;
258
+	  res = 100;
259
+	  break;
259 260
 	}
260 261
 	strm.next_out = (uint8_t *)obuf;
261 262
 	strm.avail_out = sizeof(obuf);
262 263
new file mode 100644
263 264
Binary files /dev/null and b/test/.split/split.clam.bz2.zipaa differ
264 265
new file mode 100644
265 266
Binary files /dev/null and b/test/.split/split.clam.bz2.zipab differ
... ...
@@ -4,7 +4,7 @@ FILES = clam-v2.rar clam-v3.rar clam.cab clam.exe.bz2 clam.exe clam.zip \
4 4
 	clam-nsis.exe clam-petite.exe clam-upack.exe clam-wwpack.exe clam.pdf\
5 5
 	clam.mail clam.ppt clam.tnef clam.ea05.exe clam.ea06.exe clam.d64.zip\
6 6
 	clam.exe.mbox.base64 clam.exe.mbox.uu clam.exe.binhex clam.ole.doc \
7
-	clam.impl.zip clam.exe.html
7
+	clam.impl.zip clam.exe.html clam.bz2.zip
8 8
 
9 9
 SPLIT_DIR=$(top_srcdir)/test/.split
10 10
 
... ...
@@ -198,7 +198,7 @@ FILES = clam-v2.rar clam-v3.rar clam.cab clam.exe.bz2 clam.exe clam.zip \
198 198
 	clam-nsis.exe clam-petite.exe clam-upack.exe clam-wwpack.exe clam.pdf\
199 199
 	clam.mail clam.ppt clam.tnef clam.ea05.exe clam.ea06.exe clam.d64.zip\
200 200
 	clam.exe.mbox.base64 clam.exe.mbox.uu clam.exe.binhex clam.ole.doc \
201
-	clam.impl.zip clam.exe.html
201
+	clam.impl.zip clam.exe.html clam.bz2.zip
202 202
 
203 203
 SPLIT_DIR = $(top_srcdir)/test/.split
204 204
 EXTRA_DIST = .split