From Ivan Sy (with minor modifications):
[obnox/wireshark/wip.git] / wiretap / i4btrace.c
index 9b9d2d6a7ca9d5e92bc8ef716b2f90ff798286a6..1b2bc080954189df02ec62c239006aa31c9e5644 100644 (file)
@@ -34,8 +34,8 @@
 #include "i4btrace.h"
 
 static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
-    long *data_offset);
-static gboolean i4btrace_seek_read(wtap *wth, long seek_off,
+    gint64 *data_offset);
+static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off,
     union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
     int *err, gchar **err_info);
 static int i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err);
@@ -49,9 +49,9 @@ static void i4btrace_close(wtap *wth);
  * Test some fields in the header to see if they make sense.
  */
 #define        I4B_HDR_IS_OK(hdr) \
-       (!((unsigned)hdr.length < 3 || (unsigned)hdr.unit > 4 || \
-           (unsigned)hdr.type > 4 || (unsigned)hdr.dir > 2 || \
-           (unsigned)hdr.trunc > 2048))
+       (!((unsigned)hdr.length < 3 || (unsigned)hdr.length > 16384 || \
+           (unsigned)hdr.unit > 4 || (unsigned)hdr.type > 4 || \
+           (unsigned)hdr.dir > 2 || (unsigned)hdr.trunc > 2048))
 
 int i4btrace_open(wtap *wth, int *err, gchar **err_info _U_)
 {
@@ -116,11 +116,11 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info _U_)
 
 /* Read the next packet */
 static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
-    long *data_offset)
+    gint64 *data_offset)
 {
        int     ret;
        i4b_trace_hdr_t hdr;
-       guint16 length;
+       guint32 length;
        void *bufp;
 
        /* Read record header. */
@@ -138,7 +138,7 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
                    hdr.length, (unsigned long)sizeof(hdr));
                return FALSE;
        }
-       length = hdr.length - sizeof(hdr);
+       length = hdr.length - (guint32)sizeof(hdr);
 
        wth->phdr.len = length;
        wth->phdr.caplen = length;
@@ -182,7 +182,7 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
 }
 
 static gboolean
-i4btrace_seek_read(wtap *wth, long seek_off,
+i4btrace_seek_read(wtap *wth, gint64 seek_off,
     union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
     int *err, gchar **err_info _U_)
 {