aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/file_wrappers.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-05-09 03:48:41 +0000
committerGuy Harris <guy@alum.mit.edu>2011-05-09 03:48:41 +0000
commit42ba70cf9c7b906c73721065e5b7425bf2ff663e (patch)
treec32eb0c5b631d592b7ba54656b44967a6489740a /wiretap/file_wrappers.c
parent37adc5c880a3b7f66893a6979b4aca5cce31019e (diff)
If a gzipped file's name ends in .caz, don't check the CRC - it's
probably a compressed file from the Windows Sniffer, and they don't bother setting the CRC. svn path=/trunk/; revision=37024
Diffstat (limited to 'wiretap/file_wrappers.c')
-rw-r--r--wiretap/file_wrappers.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c
index 8beaf6674c..681878bd7e 100644
--- a/wiretap/file_wrappers.c
+++ b/wiretap/file_wrappers.c
@@ -98,6 +98,7 @@ struct wtap_reader {
#ifdef HAVE_LIBZ
/* zlib inflate stream */
z_stream strm; /* stream structure in-place (not a pointer) */
+ int dont_check_crc; /* 1 if we aren't supposed to check the CRC */
#endif
/* fast seeking */
GPtrArray *fast_seek;
@@ -505,7 +506,7 @@ zlib_read(FILE_T state, unsigned char *buf, unsigned int count)
if (ret == Z_STREAM_END) {
if (gz_next4(state, &crc) != -1 &&
gz_next4(state, &len) != -1) {
- if (crc != strm->adler) {
+ if (crc != strm->adler && !state->dont_check_crc) {
state->err = WTAP_ERR_DECOMPRESS;
state->err_info = "bad CRC";
} else if (len != (strm->total_out & 0xffffffffL)) {
@@ -785,6 +786,9 @@ filed_open(int fd)
errno = ENOMEM;
return NULL;
}
+
+ /* for now, assume we should check the crc */
+ state->dont_check_crc = 0;
#endif
/* return stream */
return state;
@@ -795,6 +799,9 @@ file_open(const char *path)
{
int fd;
FILE_T ft;
+#ifdef HAVE_LIBZ
+ const char *suffixp;
+#endif
/* open file and do correct filename conversions.
@@ -805,7 +812,7 @@ file_open(const char *path)
here. Pre-Large File Summit UN*Xes, and possibly even some
post-LFS UN*Xes, might require O_LARGEFILE here, though.
If so, we should probably handle that in ws_open(). */
- if ((fd = ws_open(path, O_RDONLY|O_BINARY, 0666)) == -1)
+ if ((fd = ws_open(path, O_RDONLY|O_BINARY, 0000)) == -1)
return NULL;
/* open file handle */
@@ -815,6 +822,19 @@ file_open(const char *path)
return NULL;
}
+#ifdef HAVE_LIBZ
+ /*
+ * If this file's name ends in ".caz", it's probably a compressed
+ * Windows Sniffer file. The compression is gzip, but they don't
+ * bother filling in the CRC; we set a flag to ignore CRC errors.
+ */
+ suffixp = strrchr(path, '.');
+ if (suffixp != NULL) {
+ if (g_ascii_strcasecmp(suffixp, ".caz") == 0)
+ ft->dont_check_crc = 1;
+ }
+#endif
+
return ft;
}