diff options
-rw-r--r-- | epan/dfilter/dfilter-macro.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-afs.c | 62 | ||||
-rw-r--r-- | epan/dissectors/packet-ansi_a.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-aodv.c | 36 | ||||
-rw-r--r-- | epan/ftypes/ftype-bytes.c | 2 | ||||
-rw-r--r-- | epan/ftypes/ftype-guid.c | 2 | ||||
-rw-r--r-- | epan/ftypes/ftype-integer.c | 2 | ||||
-rw-r--r-- | epan/ftypes/ftype-pcre.c | 2 | ||||
-rw-r--r-- | wiretap/airopeek9.c | 10 | ||||
-rw-r--r-- | wiretap/erf.c | 36 | ||||
-rw-r--r-- | wiretap/eyesdn.c | 22 | ||||
-rw-r--r-- | wiretap/iptrace.c | 4 | ||||
-rw-r--r-- | wiretap/k12.c | 206 | ||||
-rw-r--r-- | wiretap/libpcap.c | 30 | ||||
-rw-r--r-- | wiretap/netmon.c | 6 | ||||
-rw-r--r-- | wiretap/network_instruments.c | 4 | ||||
-rw-r--r-- | wiretap/netxray.c | 10 | ||||
-rw-r--r-- | wiretap/ngsniffer.c | 2 | ||||
-rw-r--r-- | wiretap/pcapng.c | 24 | ||||
-rw-r--r-- | wiretap/pppdump.c | 16 | ||||
-rw-r--r-- | wiretap/snoop.c | 18 | ||||
-rw-r--r-- | wiretap/visual.c | 2 | ||||
-rw-r--r-- | wiretap/vms.c | 2 |
23 files changed, 248 insertions, 256 deletions
diff --git a/epan/dfilter/dfilter-macro.c b/epan/dfilter/dfilter-macro.c index 0de956aaa6..7e0e336e48 100644 --- a/epan/dfilter/dfilter-macro.c +++ b/epan/dfilter/dfilter-macro.c @@ -547,7 +547,7 @@ static void* macro_copy(void* dest, const void* orig, unsigned len _U_) { */ do nparts++; while (m->parts[nparts]); - d->parts = g_memdup(m->parts,(nparts+1)*sizeof(void*)); + d->parts = g_memdup(m->parts,(nparts+1)*(guint)sizeof(void*)); nparts = 0; while(m->parts[nparts]) { if(nparts) { @@ -562,7 +562,7 @@ static void* macro_copy(void* dest, const void* orig, unsigned len _U_) { * Clone the contents of m->args_pos into d->args_pos. */ - d->args_pos = g_memdup(m->args_pos,(--nparts)*sizeof(int)); + d->args_pos = g_memdup(m->args_pos,(--nparts)*(guint)sizeof(int)); } DUMP_MACRO(d); diff --git a/epan/dissectors/packet-afs.c b/epan/dissectors/packet-afs.c index 08968ed040..c49df61003 100644 --- a/epan/dissectors/packet-afs.c +++ b/epan/dissectors/packet-afs.c @@ -335,13 +335,13 @@ static gint ett_afs_vldb_flags = -1; /* Output a unsigned integer, stored into field 'field' Assumes it is in network byte order, converts to host before using */ #define OUT_UINT(field) \ - proto_tree_add_uint(tree, field, tvb, offset, sizeof(guint32), tvb_get_ntohl(tvb, offset)); \ + proto_tree_add_uint(tree, field, tvb, offset, 4, tvb_get_ntohl(tvb, offset)); \ offset += 4; /* Output a unsigned integer, stored into field 'field' Assumes it is in network byte order, converts to host before using */ #define OUT_INT(field) \ - proto_tree_add_int(tree, field, tvb, offset, sizeof(gint32), tvb_get_ntohl(tvb, offset)); \ + proto_tree_add_int(tree, field, tvb, offset, 4, tvb_get_ntohl(tvb, offset)); \ offset += 4; /* Output a unsigned integer, stored into field 'field' @@ -360,11 +360,11 @@ static gint ett_afs_vldb_flags = -1; Assumes it is in network byte order, converts to host before using, Note - does not increment offset, so can be used repeatedly for bitfields */ #define DISP_UINT(field) \ - proto_tree_add_uint(tree,field,tvb,offset,sizeof(guint32),tvb_get_ntohl(tvb, offset)); + proto_tree_add_uint(tree,field,tvb,offset,4,tvb_get_ntohl(tvb, offset)); /* Output an IPv4 address, stored into field 'field' */ #define OUT_IP(field) \ - proto_tree_add_ipv4(tree,field,tvb,offset,sizeof(gint32),\ + proto_tree_add_ipv4(tree,field,tvb,offset,4,\ tvb_get_letohl(tvb, offset));\ offset += 4; @@ -384,7 +384,7 @@ static gint ett_afs_vldb_flags = -1; { \ unsigned int j,i; \ j = tvb_get_ntohl(tvb, offset); \ - offset += sizeof(guint32); \ + offset += 4; \ for (i=0; i<j; i++) { \ func; \ } \ @@ -396,7 +396,7 @@ static gint ett_afs_vldb_flags = -1; { nstime_t ts; \ ts.secs = tvb_get_ntohl(tvb, offset); \ ts.nsecs = tvb_get_ntohl(tvb, offset+4)*1000; \ - proto_tree_add_time(tree,field, tvb,offset,2*sizeof(guint32),&ts); \ + proto_tree_add_time(tree,field, tvb,offset,2*4,&ts); \ offset += 8; \ } @@ -407,7 +407,7 @@ static gint ett_afs_vldb_flags = -1; { nstime_t ts; \ ts.secs = tvb_get_ntohl(tvb, offset); \ ts.nsecs = 0; \ - proto_tree_add_time(tree,field, tvb,offset,sizeof(guint32),&ts); \ + proto_tree_add_time(tree,field, tvb,offset,4,&ts); \ offset += 4; \ } @@ -437,10 +437,10 @@ static gint ett_afs_vldb_flags = -1; for (i_orxsv=0; i_orxsv<length; i_orxsv++)\ {\ tmp_orxsv[i_orxsv] = (char) tvb_get_ntohl(tvb, offset);\ - offset += sizeof(guint32);\ + offset += 4;\ }\ tmp_orxsv[length] = '\0';\ - proto_tree_add_string(tree, field, tvb, soff_orxsv, length*sizeof(guint32), tmp_orxsv);\ + proto_tree_add_string(tree, field, tvb, soff_orxsv, length*4, tmp_orxsv);\ } @@ -487,21 +487,21 @@ static gint ett_afs_vldb_flags = -1; guint32 mask_ofsm; \ mask_ofsm = tvb_get_ntohl(tvb, offset); \ ti_ofsm = proto_tree_add_uint(tree, hf_afs_fs_status_mask, tvb, offset, \ - sizeof(guint32), mask_ofsm); \ + 4, mask_ofsm); \ save_ofsm = tree; \ tree = proto_item_add_subtree(ti_ofsm, ett_afs_status_mask); \ proto_tree_add_boolean(tree, hf_afs_fs_status_mask_setmodtime, \ - tvb,offset,sizeof(guint32), mask_ofsm); \ + tvb,offset,4, mask_ofsm); \ proto_tree_add_boolean(tree, hf_afs_fs_status_mask_setowner, \ - tvb,offset,sizeof(guint32), mask_ofsm); \ + tvb,offset,4, mask_ofsm); \ proto_tree_add_boolean(tree, hf_afs_fs_status_mask_setgroup, \ - tvb,offset,sizeof(guint32), mask_ofsm); \ + tvb,offset,4, mask_ofsm); \ proto_tree_add_boolean(tree, hf_afs_fs_status_mask_setmode, \ - tvb,offset,sizeof(guint32), mask_ofsm); \ + tvb,offset,4, mask_ofsm); \ proto_tree_add_boolean(tree, hf_afs_fs_status_mask_setsegsize, \ - tvb,offset,sizeof(guint32), mask_ofsm); \ + tvb,offset,4, mask_ofsm); \ proto_tree_add_boolean(tree, hf_afs_fs_status_mask_fsync, \ - tvb,offset,sizeof(guint32), mask_ofsm); \ + tvb,offset,4, mask_ofsm); \ offset += 4; \ tree = save_ofsm; \ } @@ -512,17 +512,17 @@ static gint ett_afs_vldb_flags = -1; guint32 flags; \ flags = tvb_get_ntohl(tvb, offset); \ ti = proto_tree_add_uint(tree, hf_afs_vldb_flags, tvb, offset, \ - sizeof(guint32), flags); \ + 4, flags); \ save = tree; \ tree = proto_item_add_subtree(ti, ett_afs_vldb_flags); \ proto_tree_add_boolean(tree, hf_afs_vldb_flags_rwexists, \ - tvb,offset,sizeof(guint32), flags); \ + tvb,offset,4, flags); \ proto_tree_add_boolean(tree, hf_afs_vldb_flags_roexists, \ - tvb,offset,sizeof(guint32), flags); \ + tvb,offset,4, flags); \ proto_tree_add_boolean(tree, hf_afs_vldb_flags_bkexists, \ - tvb,offset,sizeof(guint32), flags); \ + tvb,offset,4, flags); \ proto_tree_add_boolean(tree, hf_afs_vldb_flags_dfsfileset, \ - tvb,offset,sizeof(guint32), flags); \ + tvb,offset,4, flags); \ offset += 4; \ tree = save; \ } @@ -677,9 +677,9 @@ static gint ett_afs_vldb_flags = -1; /* Output a UUID */ #define OUT_UUID(x) \ - OUT_BYTES(x, 11*sizeof(guint32)); + OUT_BYTES(x, 11*4); #define SKIP_UUID() \ - SKIP(11*sizeof(guint32)); + SKIP(11*4); /* Output a bulkaddr */ @@ -783,7 +783,7 @@ static gint ett_afs_vldb_flags = -1; /* Skip the opcode */ #define SKIP_OPCODE() \ { \ - SKIP(sizeof(guint32)); \ + SKIP(4); \ } /* Output a UBIK version code */ @@ -803,12 +803,12 @@ static gint ett_afs_vldb_flags = -1; tree = proto_item_add_subtree(ti, ett_afs_ubikver); \ if ( epoch != 0 ) \ proto_tree_add_time(tree,hf_afs_ubik_version_epoch, tvb,offset-8, \ - sizeof(guint32),&ts); \ + 4,&ts); \ else \ proto_tree_add_text(tree, tvb, offset-8, \ - sizeof(guint32),"Epoch: 0"); \ + 4,"Epoch: 0"); \ proto_tree_add_uint(tree,hf_afs_ubik_version_counter, tvb,offset-4, \ - sizeof(guint32),counter); \ + 4,counter); \ tree = save; \ } @@ -2649,7 +2649,7 @@ dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int o } SKIP(4); } - SKIP(8 * sizeof(guint32)); + SKIP(8 * 4); OUT_UINT(hf_afs_vldb_rwvol); OUT_UINT(hf_afs_vldb_rovol); OUT_UINT(hf_afs_vldb_bkvol); @@ -2697,7 +2697,7 @@ dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int o } SKIP(4); } - SKIP(13 * sizeof(guint32)); + SKIP(13 * 4); OUT_UINT(hf_afs_vldb_rwvol); OUT_UINT(hf_afs_vldb_rovol); OUT_UINT(hf_afs_vldb_bkvol); @@ -2729,7 +2729,7 @@ dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int o } else { - SKIP(sizeof(guint32)); + SKIP(4); } } for (i=0; i<13; i++) @@ -2754,7 +2754,7 @@ dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int o } else { - SKIP(sizeof(guint32)); + SKIP(4); } } OUT_UINT(hf_afs_vldb_rwvol); diff --git a/epan/dissectors/packet-ansi_a.c b/epan/dissectors/packet-ansi_a.c index e80f6e3908..c9b0b019f8 100644 --- a/epan/dissectors/packet-ansi_a.c +++ b/epan/dissectors/packet-ansi_a.c @@ -12147,7 +12147,7 @@ proto_register_ansi_a(void) register_dissector_table("ansi_a.pld", "IS-801 (PLD)", FT_UINT8, BASE_DEC); - proto_register_subtree_array(ett, ett_len / sizeof(gint *)); + proto_register_subtree_array(ett, ett_len / (int)sizeof(gint *)); ansi_a_tap = register_tap("ansi_a"); diff --git a/epan/dissectors/packet-aodv.c b/epan/dissectors/packet-aodv.c index 5d319dc14c..288d74566e 100644 --- a/epan/dissectors/packet-aodv.c +++ b/epan/dissectors/packet-aodv.c @@ -152,8 +152,7 @@ dissect_aodv_ext(tvbuff_t * tvb, int offset, proto_tree * tree) { proto_tree *ext_tree; proto_item *ti; - aodv_ext_t aodvext, *ext; - int len; + guint8 type, len; if (!tree) return; @@ -162,32 +161,27 @@ dissect_aodv_ext(tvbuff_t * tvb, int offset, proto_tree * tree) if ((int) tvb_reported_length(tvb) <= offset) return; /* No more options left */ - ext = &aodvext; - tvb_memcpy(tvb, (guint8 *) ext, offset, sizeof(*ext)); - len = ext->length; + type = tvb_get_guint8(tvb, offset); + len = tvb_get_guint8(tvb, offset + 1); - ti = proto_tree_add_text(tree, tvb, offset, sizeof(aodv_ext_t) + - len, "Extensions"); + ti = proto_tree_add_text(tree, tvb, offset, 2 + len, "Extensions"); ext_tree = proto_item_add_subtree(ti, ett_aodv_extensions); + proto_tree_add_text(ext_tree, tvb, offset, 1, + "Type: %u (%s)", type, + val_to_str(type, exttype_vals, "Unknown")); + if (len == 0) { - proto_tree_add_text(ext_tree, tvb, - offset + offsetof(aodv_ext_t, length), 1, - "Invalid option length: %u", ext->length); + proto_tree_add_text(ext_tree, tvb, offset + 1, 1, + "Invalid option length: %u", len); return; /* we must not try to decode this */ } + proto_tree_add_text(ext_tree, tvb, offset + 1, 1, + "Length: %u bytes", len); - proto_tree_add_text(ext_tree, tvb, - offset + offsetof(aodv_ext_t, type), 1, - "Type: %u (%s)", ext->type, - val_to_str(ext->type, exttype_vals, "Unknown")); - proto_tree_add_text(ext_tree, tvb, - offset + offsetof(aodv_ext_t, length), 1, - "Length: %u bytes", ext->length); - - offset += sizeof(aodv_ext_t); + offset += 2; - switch (ext->type) { + switch (type) { case AODV_EXT_INT: proto_tree_add_uint(ext_tree, hf_aodv_ext_interval, tvb, offset, 4, tvb_get_ntohl(tvb, offset)); @@ -202,7 +196,7 @@ dissect_aodv_ext(tvbuff_t * tvb, int offset, proto_tree * tree) /* If multifield extensions appear, we need more * sophisticated handler. For now, this is okay. */ - offset += ext->length; + offset += len; goto again; } diff --git a/epan/ftypes/ftype-bytes.c b/epan/ftypes/ftype-bytes.c index 19f2ba0eda..c8d33a16d9 100644 --- a/epan/ftypes/ftype-bytes.c +++ b/epan/ftypes/ftype-bytes.c @@ -494,7 +494,7 @@ cmp_matches(fvalue_t *fv_a, fvalue_t *fv_b) pcre_t->re, /* Compiled PCRE */ pcre_t->ex, /* PCRE extra from pcre_study() */ a->str, /* The data to check for the pattern... */ - a->len, /* ... and its length */ + (int)a->len, /* ... and its length */ 0, /* Start offset within data */ options, /* PCRE options */ NULL, /* We are not interested in the matched string */ diff --git a/epan/ftypes/ftype-guid.c b/epan/ftypes/ftype-guid.c index 622da5f4d2..c171b55ef6 100644 --- a/epan/ftypes/ftype-guid.c +++ b/epan/ftypes/ftype-guid.c @@ -66,7 +66,7 @@ get_guid(char *s, e_guid_t *guid) p = s; strncpy(digits, p, 8); digits[8] = '\0'; - guid->data1 = strtoul(digits, NULL, 16); + guid->data1 = (guint32)strtoul(digits, NULL, 16); p += 9; strncpy(digits, p, 4); digits[4] = '\0'; diff --git a/epan/ftypes/ftype-integer.c b/epan/ftypes/ftype-integer.c index 8a3bb5aa7a..d12b38e4d5 100644 --- a/epan/ftypes/ftype-integer.c +++ b/epan/ftypes/ftype-integer.c @@ -102,7 +102,7 @@ val_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFu return FALSE; } - fv->value.uinteger = value; + fv->value.uinteger = (guint32)value; return TRUE; } diff --git a/epan/ftypes/ftype-pcre.c b/epan/ftypes/ftype-pcre.c index 01b01f1bb1..2edd34b8bf 100644 --- a/epan/ftypes/ftype-pcre.c +++ b/epan/ftypes/ftype-pcre.c @@ -145,7 +145,7 @@ static int pcre_repr_len(fvalue_t *fv, ftrepr_t rtype) { g_assert(rtype == FTREPR_DFILTER); - return strlen(fv->value.re->string); + return (int)strlen(fv->value.re->string); } static void diff --git a/wiretap/airopeek9.c b/wiretap/airopeek9.c index c96ec5cb4f..2663aa5123 100644 --- a/wiretap/airopeek9.c +++ b/wiretap/airopeek9.c @@ -173,9 +173,9 @@ static int wtap_file_read_number (wtap *wth, guint32 *num, int *err) return ret; } value = strtoul (str_num, &p, 10); - if (p == str_num || value > UINT_MAX) + if (p == str_num || value > G_MAXUINT32) return 0; - *num = value; + *num = (guint32)value; return 1; } @@ -345,11 +345,11 @@ typedef struct { * dissector can determine which, if any, information items * are present. */ -static int +static ssize_t airopeekv9_process_header(FILE_T fh, hdr_info_t *hdr_info, int *err, gchar **err_info) { - long header_len = 0; + ssize_t header_len = 0; int bytes_read; guint8 tag_value[6]; guint16 tag; @@ -486,7 +486,7 @@ static gboolean airopeekv9_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { hdr_info_t hdr_info; - int hdrlen; + ssize_t hdrlen; double t; *data_offset = wth->data_offset; diff --git a/wiretap/erf.c b/wiretap/erf.c index 2743273ae0..5e88a64ddc 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -126,7 +126,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info _U_) rlen=g_ntohs(header.rlen); wlen=g_ntohs(header.wlen); - packet_size = rlen - sizeof(header); + packet_size = rlen - (guint32)sizeof(header); /* fail on invalid record type, invalid rlen, timestamps decreasing, or incrementing too far */ @@ -183,7 +183,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info _U_) *err = file_error(wth->fh); return -1; } - packet_size -= sizeof(erf_ext_header); + packet_size -= (guint32)sizeof(erf_ext_header); memcpy(&type, &erf_ext_header, sizeof(type)); } @@ -201,7 +201,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info _U_) *err = file_error(wth->fh); return -1; } - packet_size -= sizeof(mc_hdr); + packet_size -= (guint32)sizeof(mc_hdr); break; case ERF_TYPE_ETH: case ERF_TYPE_COLOR_ETH: @@ -210,7 +210,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info _U_) *err = file_error(wth->fh); return -1; } - packet_size -= sizeof(eth_hdr); + packet_size -= (guint32)sizeof(eth_hdr); break; default: break; @@ -315,16 +315,16 @@ static int erf_read_header(FILE_T fh, guint8 erf_exhdr[8]; guint64 erf_exhdr_sw; guint8 type = 0; - guint16 eth_hdr,skiplen=0; + guint16 eth_hdr; + guint32 skiplen=0; int i = 0 , max = sizeof(pseudo_header->erf.ehdr_list)/sizeof(struct erf_ehdr); -; wtap_file_read_expected_bytes(erf_header, sizeof(*erf_header), fh, err); if (bytes_read != NULL) { *bytes_read = sizeof(*erf_header); } - *packet_size = g_ntohs(erf_header->rlen) - sizeof(*erf_header); + *packet_size = g_ntohs(erf_header->rlen) - (guint32)sizeof(*erf_header); if (*packet_size > WTAP_MAX_PACKET_SIZE) { /* @@ -343,7 +343,7 @@ static int erf_read_header(FILE_T fh, phdr->ts.secs = (long) (ts >> 32); ts = ((ts & 0xffffffff) * 1000 * 1000 * 1000); ts += (ts & 0x80000000) << 1; /* rounding */ - phdr->ts.nsecs = ((long) (ts >> 32)); + phdr->ts.nsecs = ((int) (ts >> 32)); if (phdr->ts.nsecs >= 1000000000) { phdr->ts.nsecs -= 1000000000; phdr->ts.secs += 1; @@ -363,9 +363,9 @@ static int erf_read_header(FILE_T fh, while (type & 0x80){ wtap_file_read_expected_bytes(&erf_exhdr, sizeof(erf_exhdr), fh, err); if (bytes_read != NULL) - *bytes_read += sizeof(erf_exhdr); - *packet_size -= sizeof(erf_exhdr); - skiplen += sizeof(erf_exhdr); + *bytes_read += (guint32)sizeof(erf_exhdr); + *packet_size -= (guint32)sizeof(erf_exhdr); + skiplen += (guint32)sizeof(erf_exhdr); erf_exhdr_sw = pntohll((guint64*) &(erf_exhdr[0])); if (i < max) memcpy(&pseudo_header->erf.ehdr_list[i].ehdr, &erf_exhdr_sw, sizeof(erf_exhdr_sw)); @@ -400,9 +400,9 @@ static int erf_read_header(FILE_T fh, case ERF_TYPE_DSM_COLOR_ETH: wtap_file_read_expected_bytes(ð_hdr, sizeof(eth_hdr), fh, err); if (bytes_read != NULL) - *bytes_read += sizeof(eth_hdr); - *packet_size -= sizeof(eth_hdr); - skiplen += sizeof(eth_hdr); + *bytes_read += (guint32)sizeof(eth_hdr); + *packet_size -= (guint32)sizeof(eth_hdr); + skiplen += (guint32)sizeof(eth_hdr); pseudo_header->erf.subhdr.eth_hdr = g_htons(eth_hdr); break; @@ -415,9 +415,9 @@ static int erf_read_header(FILE_T fh, case ERF_TYPE_COLOR_MC_HDLC_POS: wtap_file_read_expected_bytes(&mc_hdr, sizeof(mc_hdr), fh, err); if (bytes_read != NULL) - *bytes_read += sizeof(mc_hdr); - *packet_size -= sizeof(mc_hdr); - skiplen += sizeof(mc_hdr); + *bytes_read += (guint32)sizeof(mc_hdr); + *packet_size -= (guint32)sizeof(mc_hdr); + skiplen += (guint32)sizeof(mc_hdr); pseudo_header->erf.subhdr.mc_hdr = g_htonl(mc_hdr); break; @@ -434,7 +434,7 @@ static int erf_read_header(FILE_T fh, if (phdr != NULL) { phdr->len = g_htons(erf_header->wlen); phdr->caplen = min( g_htons(erf_header->wlen), - g_htons(erf_header->rlen) - sizeof(*erf_header) - skiplen ); + g_htons(erf_header->rlen) - (guint32)sizeof(*erf_header) - skiplen ); } return TRUE; } diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c index 3909ec5723..c8bd71be0b 100644 --- a/wiretap/eyesdn.c +++ b/wiretap/eyesdn.c @@ -41,7 +41,7 @@ * 7-n Byte: Frames * * Each Frame starts with the 0xff Flag byte - * - Bytes 0-2: timestamp (long usec in network byte order) + * - Bytes 0-2: timestamp (usec in network byte order) * - Bytes 3-7: timestamp (40bits sec since 1970 in network byte order) * - Byte 8: channel (0 for D channel, 1-30 for B1-B30) * - Byte 9: Sender Bit 0(0 NT, 1 TE), Protocol in Bits 7:1, see enum @@ -235,7 +235,8 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info) { guint8 hdr[EYESDN_HDR_LENGTH]; - unsigned long secs, usecs; + time_t secs; + int usecs; int pkt_len; guint8 channel, direction; @@ -251,23 +252,20 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh, } /* extract information from header */ - usecs = ((unsigned long) hdr[0]); - usecs = (usecs << 8) | ((unsigned long) hdr[1]); - usecs = (usecs << 8) | ((unsigned long) hdr[2]); + usecs = pntoh24(&hdr[0]); #ifdef TV64BITS - secs = ((unsigned long) hdr[3]); + secs = hdr[3]; #else secs = 0; #endif - secs = (secs << 8) | ((unsigned long) hdr[4]); - secs = (secs << 8) | ((unsigned long) hdr[5]); - secs = (secs << 8) | ((unsigned long) hdr[6]); - secs = (secs << 8) | ((unsigned long) hdr[7]); + secs = (secs << 8) | hdr[4]; + secs = (secs << 8) | hdr[5]; + secs = (secs << 8) | hdr[6]; + secs = (secs << 8) | hdr[7]; channel = hdr[8]; direction = hdr[9]; - pkt_len = ((unsigned long) hdr[10]); - pkt_len = (pkt_len << 8) | ((unsigned long) hdr[11]); + pkt_len = pntohs(&hdr[10]); switch(direction >> 1) { default: diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c index 2a50dad172..960d36eaf4 100644 --- a/wiretap/iptrace.c +++ b/wiretap/iptrace.c @@ -514,9 +514,9 @@ fill_in_pseudo_header(int encap, const guint8 *pd, guint32 len, decimal = strchr(if_text, '.'); if (decimal) { *decimal = '\0'; - Vpi = strtoul(if_text, NULL, 10); + Vpi = (int)strtoul(if_text, NULL, 10); decimal++; - Vci = strtoul(decimal, NULL, 10); + Vci = (int)strtoul(decimal, NULL, 10); } /* diff --git a/wiretap/k12.c b/wiretap/k12.c index f9952f778e..adb33afc07 100644 --- a/wiretap/k12.c +++ b/wiretap/k12.c @@ -210,30 +210,30 @@ typedef struct _k12_src_desc_t { * XXX: works at most with 0x1FFF bytes per record */ static gint get_record(guint8** bufferp, FILE* fh, gint64 file_offset) { - static guint8* buffer = NULL; - static guint buffer_len = 0x2000 ; - guint bytes_read; - guint last_read; - guint actual_len, left; - guint8 junk[0x14]; - guint8* writep; - - /* where the next unknown 0x10 bytes are stuffed to the file */ - guint junky_offset = 0x2000 - (gint) ( (file_offset - 0x200) % 0x2000 ); - - K12_DBG(6,("get_record: ENTER: junky_offset=%" G_GINT64_MODIFIER "d, file_offset=%" G_GINT64_MODIFIER "d",junky_offset,file_offset)); - - /* no buffer is given, lets create it */ - if (buffer == NULL) { - buffer = g_malloc(0x2000); - buffer_len = 0x2000; - } + static guint8* buffer = NULL; + static guint buffer_len = 0x2000 ; + guint bytes_read; + guint last_read; + guint actual_len, left; + guint8 junk[0x14]; + guint8* writep; + + /* where the next unknown 0x10 bytes are stuffed to the file */ + guint junky_offset = 0x2000 - (gint) ( (file_offset - 0x200) % 0x2000 ); + + K12_DBG(6,("get_record: ENTER: junky_offset=%" G_GINT64_MODIFIER "d, file_offset=%" G_GINT64_MODIFIER "d",junky_offset,file_offset)); + + /* no buffer is given, lets create it */ + if (buffer == NULL) { + buffer = g_malloc(0x2000); + buffer_len = 0x2000; + } - *bufferp = buffer; + *bufferp = buffer; - if ( junky_offset == 0x2000 ) { - /* the length of the record is 0x10 bytes ahead from we are reading */ - bytes_read = file_read(junk,1,0x14,fh); + if ( junky_offset == 0x2000 ) { + /* the length of the record is 0x10 bytes ahead from we are reading */ + bytes_read = file_read(junk,1,0x14,fh); if (bytes_read == 2 && junk[0] == 0xff && junk[1] == 0xff) { K12_DBG(1,("get_record: EOF")); @@ -243,84 +243,84 @@ static gint get_record(guint8** bufferp, FILE* fh, gint64 file_offset) { return -1; } - memcpy(buffer,&(junk[0x10]),4); - } else { - /* the length of the record is right where we are reading */ - bytes_read = file_read(buffer,1, 0x4, fh); + memcpy(buffer,&(junk[0x10]),4); + } else { + /* the length of the record is right where we are reading */ + bytes_read = file_read(buffer,1, 0x4, fh); - if (bytes_read == 2 && buffer[0] == 0xff && buffer[1] == 0xff) { + if (bytes_read == 2 && buffer[0] == 0xff && buffer[1] == 0xff) { K12_DBG(1,("get_record: EOF")); return 0; } else if ( bytes_read != 0x4 ) { K12_DBG(1,("get_record: SHORT READ")); return -1; } - } + } - actual_len = left = pntohl(buffer); - junky_offset -= 0x4; + actual_len = left = pntohl(buffer); + junky_offset -= 0x4; - K12_DBG(5,("get_record: GET length=%u",left)); + K12_DBG(5,("get_record: GET length=%u",left)); - /* XXX - Is WTAP_MAX_PACKET_SIZE */ - if (left < 4 || left > WTAP_MAX_PACKET_SIZE) { - K12_DBG(1,("get_record: Invalid GET length=%u",left)); - errno = WTAP_ERR_BAD_RECORD; - return -1; - } + /* XXX - Is WTAP_MAX_PACKET_SIZE */ + if (left < 4 || left > WTAP_MAX_PACKET_SIZE) { + K12_DBG(1,("get_record: Invalid GET length=%u",left)); + errno = WTAP_ERR_BAD_RECORD; + return -1; + } - while (left > buffer_len) *bufferp = buffer = g_realloc(buffer,buffer_len*=2); + while (left > buffer_len) *bufferp = buffer = g_realloc(buffer,buffer_len*=2); - writep = buffer + 4; - left -= 4; + writep = buffer + 4; + left -= 4; - do { - K12_DBG(6,("get_record: looping left=%d junky_offset=%" G_GINT64_MODIFIER "d",left,junky_offset)); + do { + K12_DBG(6,("get_record: looping left=%d junky_offset=%" G_GINT64_MODIFIER "d",left,junky_offset)); - if (junky_offset > left) { - bytes_read += last_read = file_read(writep,1, left, fh); + if (junky_offset > left) { + bytes_read += last_read = file_read(writep,1, left, fh); - if ( last_read != left ) { - K12_DBG(1,("get_record: SHORT READ")); - return -1; - } else { - K12_HEXDMP(5,file_offset, "GOT record", buffer, actual_len); - return bytes_read; - } - } else { - bytes_read += last_read = file_read(writep,1, junky_offset, fh); + if ( last_read != left ) { + K12_DBG(1,("get_record: SHORT READ")); + return -1; + } else { + K12_HEXDMP(5,file_offset, "GOT record", buffer, actual_len); + return bytes_read; + } + } else { + bytes_read += last_read = file_read(writep,1, junky_offset, fh); - if ( last_read != junky_offset ) { - K12_DBG(1,("get_record: SHORT READ, read=%d expected=%d",last_read, junky_offset)); - return -1; - } + if ( last_read != junky_offset ) { + K12_DBG(1,("get_record: SHORT READ, read=%d expected=%d",last_read, junky_offset)); + return -1; + } - writep += last_read; + writep += last_read; - bytes_read += last_read = file_read(junk,1, 0x10, fh); + bytes_read += last_read = file_read(junk,1, 0x10, fh); - if ( last_read != 0x10 ) { - K12_DBG(1,("get_record: SHORT READ")); - return -1; - } + if ( last_read != 0x10 ) { + K12_DBG(1,("get_record: SHORT READ")); + return -1; + } - left -= junky_offset; - junky_offset = 0x2000; - } + left -= junky_offset; + junky_offset = 0x2000; + } - } while(left); + } while(left); - K12_HEXDMP(5,file_offset, "GOT record", buffer, actual_len); - return bytes_read; + K12_HEXDMP(5,file_offset, "GOT record", buffer, actual_len); + return bytes_read; } static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset) { k12_src_desc_t* src_desc; guint8* buffer = NULL; gint64 offset; - long len; + gint len; guint32 type; - guint32 src_id; + guint32 src_id; guint64 ts; guint32 extra_len; @@ -328,7 +328,7 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data /* ignore the record if it isn't a packet */ do { - K12_DBG(5,("k12_read: offset=%i",offset)); + K12_DBG(5,("k12_read: offset=%i",offset)); *data_offset = offset; @@ -347,15 +347,15 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data if ( ! (src_desc = g_hash_table_lookup(wth->capture.k12->src_by_id,GUINT_TO_POINTER(src_id))) ) { - /* - * Some records from K15 files have a port ID of an undeclared - * interface which happens to be the only one with the first byte changed. - * It is still unknown how to recognize when this happens. - * If the lookup of the interface record fails we'll mask it - * and retry. - */ - src_desc = g_hash_table_lookup(wth->capture.k12->src_by_id,GUINT_TO_POINTER(src_id&K12_RECORD_SRC_ID_MASK)); - } + /* + * Some records from K15 files have a port ID of an undeclared + * interface which happens to be the only one with the first byte changed. + * It is still unknown how to recognize when this happens. + * If the lookup of the interface record fails we'll mask it + * and retry. + */ + src_desc = g_hash_table_lookup(wth->capture.k12->src_by_id,GUINT_TO_POINTER(src_id&K12_RECORD_SRC_ID_MASK)); + } K12_DBG(5,("k12_read: record type=%x src_id=%x",type,src_id)); @@ -389,26 +389,26 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data wth->pseudo_header.k12.input = src_id; K12_DBG(5,("k12_read: wth->pseudo_header.k12.input=%x wth->phdr.len=%i input_name='%s' stack_file='%s' type=%x", - wth->pseudo_header.k12.input,wth->phdr.len,src_desc->input_name,src_desc->stack_file,src_desc->input_type));\ - - wth->pseudo_header.k12.input_name = src_desc->input_name; - wth->pseudo_header.k12.stack_file = src_desc->stack_file; - wth->pseudo_header.k12.input_type = src_desc->input_type; - - switch(src_desc->input_type) { - case K12_PORT_ATMPVC: - if ((long)(K12_PACKET_FRAME + wth->phdr.len + K12_PACKET_OFFSET_CID) < len) { - wth->pseudo_header.k12.input_info.atm.vp = pntohs(buffer + (K12_PACKET_FRAME + wth->phdr.caplen + K12_PACKET_OFFSET_VP)); - wth->pseudo_header.k12.input_info.atm.vc = pntohs(buffer + (K12_PACKET_FRAME + wth->phdr.caplen + K12_PACKET_OFFSET_VC)); - wth->pseudo_header.k12.input_info.atm.cid = *((unsigned char*)(buffer + K12_PACKET_FRAME + wth->phdr.len + K12_PACKET_OFFSET_CID)); - break; - } - /* Fall through */ - default: - memcpy(&(wth->pseudo_header.k12.input_info),&(src_desc->input_info),sizeof(src_desc->input_info)); - break; + wth->pseudo_header.k12.input,wth->phdr.len,src_desc->input_name,src_desc->stack_file,src_desc->input_type));\ - } + wth->pseudo_header.k12.input_name = src_desc->input_name; + wth->pseudo_header.k12.stack_file = src_desc->stack_file; + wth->pseudo_header.k12.input_type = src_desc->input_type; + + switch(src_desc->input_type) { + case K12_PORT_ATMPVC: + if ((long)(K12_PACKET_FRAME + wth->phdr.len + K12_PACKET_OFFSET_CID) < len) { + wth->pseudo_header.k12.input_info.atm.vp = pntohs(buffer + (K12_PACKET_FRAME + wth->phdr.caplen + K12_PACKET_OFFSET_VP)); + wth->pseudo_header.k12.input_info.atm.vc = pntohs(buffer + (K12_PACKET_FRAME + wth->phdr.caplen + K12_PACKET_OFFSET_VC)); + wth->pseudo_header.k12.input_info.atm.cid = *((unsigned char*)(buffer + K12_PACKET_FRAME + wth->phdr.len + K12_PACKET_OFFSET_CID)); + break; + } + /* Fall through */ + default: + memcpy(&(wth->pseudo_header.k12.input_info),&(src_desc->input_info),sizeof(src_desc->input_info)); + break; + + } wth->pseudo_header.k12.stuff = wth->capture.k12; @@ -419,7 +419,7 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data static gboolean k12_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err _U_, gchar **err_info _U_) { k12_src_desc_t* src_desc; guint8* buffer; - long len; + gint len; guint32 extra_len; guint32 input; @@ -743,7 +743,7 @@ static gboolean do_fwrite(const void *data, size_t size, size_t count, FILE *str return TRUE; } -static gboolean k12_dump_record(wtap_dumper *wdh, long len, guint8* buffer, int *err_p) { +static gboolean k12_dump_record(wtap_dumper *wdh, guint32 len, guint8* buffer, int *err_p) { long junky_offset = (0x2000 - ( (wdh->dump.k12->file_offset - 0x200) % 0x2000 )) % 0x2000; if (len > junky_offset) { @@ -879,7 +879,7 @@ static void k12_dump_src_setting(gpointer k _U_, gpointer v, gpointer p) { static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err) { - long len; + guint32 len; union { guint8 buffer[0x2000]; struct { diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index 74b85f1805..8cbde58113 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -1467,8 +1467,8 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info, /* * Don't count the pseudo-header as part of the packet. */ - orig_size -= sizeof (struct linux_usb_phdr); - packet_size -= sizeof (struct linux_usb_phdr); + orig_size -= (guint)sizeof (struct linux_usb_phdr); + packet_size -= (guint)sizeof (struct linux_usb_phdr); wth->data_offset += sizeof (struct linux_usb_phdr); break; @@ -1495,8 +1495,8 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info, /* * Don't count the pseudo-header as part of the packet. */ - orig_size -= sizeof (struct libpcap_bt_phdr); - packet_size -= sizeof (struct libpcap_bt_phdr); + orig_size -= (guint)sizeof (struct libpcap_bt_phdr); + packet_size -= (guint)sizeof (struct libpcap_bt_phdr); wth->data_offset += sizeof (struct libpcap_bt_phdr); break; @@ -1518,8 +1518,8 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info, /* * Don't count the pseudo-header as part of the packet. */ - orig_size -= sizeof(struct erf_phdr); - packet_size -= sizeof(struct erf_phdr); + orig_size -= (guint)sizeof(struct erf_phdr); + packet_size -= (guint)sizeof(struct erf_phdr); wth->data_offset += sizeof(struct erf_phdr); if (!libpcap_read_erf_exheader(wth->fh, &wth->pseudo_header, @@ -1563,8 +1563,8 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info, /* * Don't count the pseudo-header as part of the packet. */ - orig_size -= sizeof (struct i2c_file_hdr); - packet_size -= sizeof (struct i2c_file_hdr); + orig_size -= (guint)sizeof (struct i2c_file_hdr); + packet_size -= (guint)sizeof (struct i2c_file_hdr); wth->data_offset += sizeof (struct i2c_file_hdr); break; @@ -2633,11 +2633,11 @@ static gboolean libpcap_dump(wtap_dumper *wdh, case WTAP_ENCAP_USB_LINUX: case WTAP_ENCAP_USB_LINUX_MMAPPED: - hdrsize = sizeof (struct linux_usb_phdr); + hdrsize = (int)sizeof (struct linux_usb_phdr); break; case WTAP_ENCAP_ERF: - hdrsize = sizeof (struct erf_phdr); + hdrsize = (int)sizeof (struct erf_phdr); if (pseudo_header->erf.phdr.type & 0x80) hdrsize += 8; switch(pseudo_header->erf.phdr.type & 0x7F) { case ERF_TYPE_MC_HDLC: @@ -2647,12 +2647,12 @@ static gboolean libpcap_dump(wtap_dumper *wdh, case ERF_TYPE_MC_AAL5: case ERF_TYPE_MC_AAL2: case ERF_TYPE_COLOR_MC_HDLC_POS: - hdrsize += sizeof(struct erf_mc_hdr); + hdrsize += (int)sizeof(struct erf_mc_hdr); break; case ERF_TYPE_ETH: case ERF_TYPE_COLOR_ETH: case ERF_TYPE_DSM_COLOR_ETH: - hdrsize += sizeof(struct erf_eth_hdr); + hdrsize += (int)sizeof(struct erf_eth_hdr); break; default: break; @@ -2660,7 +2660,7 @@ static gboolean libpcap_dump(wtap_dumper *wdh, break; case WTAP_ENCAP_I2C: - hdrsize = sizeof (struct i2c_file_hdr); + hdrsize = (int)sizeof (struct i2c_file_hdr); break; default: @@ -2917,13 +2917,13 @@ static gboolean libpcap_dump(wtap_dumper *wdh, case ERF_TYPE_MC_AAL2: case ERF_TYPE_COLOR_MC_HDLC_POS: phtonl(&erf_hdr[16], pseudo_header->erf.subhdr.mc_hdr); - size += sizeof(struct erf_mc_hdr); + size += (int)sizeof(struct erf_mc_hdr); break; case ERF_TYPE_ETH: case ERF_TYPE_COLOR_ETH: case ERF_TYPE_DSM_COLOR_ETH: phtons(&erf_hdr[16], pseudo_header->erf.subhdr.eth_hdr); - size += sizeof(struct erf_eth_hdr); + size += (int)sizeof(struct erf_eth_hdr); break; default: break; diff --git a/wiretap/netmon.c b/wiretap/netmon.c index 985a8c9f9e..66b1cacad6 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -256,7 +256,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info) * in it as the offsets of the frames. */ frame_table_length = pletohl(&hdr.frametablelength); - frame_table_size = frame_table_length / sizeof (guint32); + frame_table_size = frame_table_length / (guint32)sizeof (guint32); if ((frame_table_size * sizeof (guint32)) != frame_table_length) { *err = WTAP_ERR_UNSUPPORTED; *err_info = g_strdup_printf("netmon: frame table length is %u, which is not a multiple of the size of an entry", @@ -420,8 +420,8 @@ static gboolean netmon_read(wtap *wth, int *err, gchar **err_info, /* * Don't count the pseudo-header as part of the packet. */ - orig_size -= sizeof (struct netmon_atm_hdr); - packet_size -= sizeof (struct netmon_atm_hdr); + orig_size -= (guint)sizeof (struct netmon_atm_hdr); + packet_size -= (guint)sizeof (struct netmon_atm_hdr); wth->data_offset += sizeof (struct netmon_atm_hdr); break; diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c index f8e63bc35e..64fdbb557d 100644 --- a/wiretap/network_instruments.c +++ b/wiretap/network_instruments.c @@ -159,7 +159,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info) } /* skip the TLV data */ - seek_increment = tlvh.length - sizeof tlvh; + seek_increment = tlvh.length - (int)sizeof tlvh; if (seek_increment > 0) { if (file_seek(wth->fh, seek_increment, SEEK_CUR, err) == -1) return -1; @@ -391,7 +391,7 @@ read_packet_header(FILE_T fh, packet_entry_header *packet_header, int *err, } /* skip the TLV data */ - seek_increment = tlvh.length - sizeof tlvh; + seek_increment = tlvh.length - (int)sizeof tlvh; if (seek_increment > 0) { if (file_seek(fh, seek_increment, SEEK_CUR, err) == -1) return -1; diff --git a/wiretap/netxray.c b/wiretap/netxray.c index 9d3a5ab6d7..7a000b16f7 100644 --- a/wiretap/netxray.c +++ b/wiretap/netxray.c @@ -996,7 +996,7 @@ reread: t /= wth->capture.netxray->ticks_per_sec; t -= wth->capture.netxray->start_timestamp; wth->phdr.ts.secs = wth->capture.netxray->start_time + (long)t; - wth->phdr.ts.nsecs = (unsigned long)((t-(double)(unsigned long)(t)) + wth->phdr.ts.nsecs = (int)((t-(double)(unsigned long)(t)) *1.0e9); /* * We subtract the padding from the packet size, so our caller @@ -1009,8 +1009,8 @@ reread: + (double)pletohl(&hdr.hdr_1_x.timehi)*4294967296.0; t /= wth->capture.netxray->ticks_per_sec; t -= wth->capture.netxray->start_timestamp; - wth->phdr.ts.secs = wth->capture.netxray->start_time + (long)t; - wth->phdr.ts.nsecs = (unsigned long)((t-(double)(unsigned long)(t)) + wth->phdr.ts.secs = wth->capture.netxray->start_time + (time_t)t; + wth->phdr.ts.nsecs = (int)((t-(double)(unsigned long)(t)) *1.0e9); /* * We subtract the padding from the packet size, so our caller @@ -1592,7 +1592,7 @@ static gboolean netxray_dump_close_1_1(wtap_dumper *wdh, int *err) struct netxray_hdr file_hdr; size_t nwritten; - filelen = ftell(wdh->fh); + filelen = (guint32)ftell(wdh->fh); /* XXX - large files? */ /* Go back to beginning */ fseek(wdh->fh, 0, SEEK_SET); @@ -1802,7 +1802,7 @@ static gboolean netxray_dump_close_2_0(wtap_dumper *wdh, int *err) struct netxray_hdr file_hdr; size_t nwritten; - filelen = ftell(wdh->fh); + filelen = (guint32)ftell(wdh->fh); /* XXX - large files? */ /* Go back to beginning */ fseek(wdh->fh, 0, SEEK_SET); diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c index cc905c6e43..912eccf25a 100644 --- a/wiretap/ngsniffer.c +++ b/wiretap/ngsniffer.c @@ -813,7 +813,7 @@ process_header_records(wtap *wth, int *err, gchar **err_info, gint16 maj_vers, * Yes, get the first up-to-256 bytes of the * record data. */ - bytes_to_read = MIN(length, sizeof buffer); + bytes_to_read = MIN(length, (int)sizeof buffer); bytes_read = file_read(buffer, 1, bytes_to_read, wth->fh); if (bytes_read != bytes_to_read) { diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index 0b524363f4..c804e98a25 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -378,9 +378,9 @@ pcapng_read_section_header_block(FILE_T fh, pcapng_block_header_t *bh, /* Options */ errno = WTAP_ERR_CANT_READ; to_read = bh->block_total_length - - sizeof(pcapng_block_header_t) - - sizeof (pcapng_section_header_block_t) - - sizeof(bh->block_total_length); + - (int)sizeof(pcapng_block_header_t) + - (int)sizeof (pcapng_section_header_block_t) + - (int)sizeof(bh->block_total_length); while(to_read > 0) { /* read option */ bytes_read = pcapng_read_option(fh, pn, &oh, option_content, sizeof(option_content), err, err_info); @@ -508,9 +508,9 @@ pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, /* Options */ errno = WTAP_ERR_CANT_READ; to_read = bh->block_total_length - - sizeof(pcapng_block_header_t) - - sizeof (pcapng_interface_description_block_t) - - sizeof(bh->block_total_length); + - (int)sizeof(pcapng_block_header_t) + - (int)sizeof (pcapng_interface_description_block_t) + - (int)sizeof(bh->block_total_length); while(to_read > 0) { /* read option */ bytes_read = pcapng_read_option(fh, pn, &oh, option_content, sizeof(option_content), err, err_info); @@ -680,9 +680,9 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta /* Options */ errno = WTAP_ERR_CANT_READ; to_read = block_total_length - - sizeof(pcapng_block_header_t) + - (int)sizeof(pcapng_block_header_t) - block_read /* fixed and variable part, including padding */ - - sizeof(bh->block_total_length); + - (int)sizeof(bh->block_total_length); while(to_read > 0) { /* read option */ bytes_read = pcapng_read_option(fh, pn, &oh, option_content, sizeof(option_content), err, err_info); @@ -759,8 +759,8 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t * } wblock->data.simple_packet.cap_len = bh->block_total_length - - sizeof(pcapng_simple_packet_block_t) - - sizeof(bh->block_total_length); + - (guint32)sizeof(pcapng_simple_packet_block_t) + - (guint32)sizeof(bh->block_total_length); /*g_pcapng_debug1("pcapng_read_simple_packet_block: packet data: packet_len %u", wblock->data.simple_packet.packet_len);*/ @@ -815,7 +815,7 @@ pcapng_read_unknown_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn _U_ block_total_length = bh->block_total_length; } - block_read = block_total_length - sizeof(bh->block_total_length); + block_read = block_total_length - (guint32)sizeof(bh->block_total_length); /* jump over this unknown block */ file_offset64 = file_seek(fh, block_read, SEEK_CUR, err); @@ -1235,7 +1235,7 @@ pcapng_write_packet_block(wtap_dumper *wdh, wtapng_block_t *wblock, int *err) /* write (enhanced) packet block header */ bh.block_type = wblock->type; - bh.block_total_length = sizeof(bh) + sizeof(epb) /* + pseudo header */ + wblock->data.packet.cap_len + cap_pad_len /* + options */ + 4; + bh.block_total_length = (guint32)sizeof(bh) + (guint32)sizeof(epb) /* + pseudo header */ + wblock->data.packet.cap_len + cap_pad_len /* + options */ + 4; nwritten = wtap_dump_file_write(wdh, &bh, sizeof bh); if (nwritten != sizeof bh) { diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c index 41efe04a1b..32fa340299 100644 --- a/wiretap/pppdump.c +++ b/wiretap/pppdump.c @@ -120,8 +120,8 @@ static gboolean pppdump_seek_read(wtap *wth, gint64 seek_off, * "dir" is the direction of the packet. */ typedef struct { - long offset; - int num_bytes_to_skip; + gint64 offset; + gint64 num_bytes_to_skip; direction_enum dir; } pkt_id; @@ -156,9 +156,9 @@ typedef struct { int cnt; gboolean esc; guint8 buf[PPPD_BUF_SIZE]; - long id_offset; - long sd_offset; - long cd_offset; + gint64 id_offset; + gint64 sd_offset; + gint64 cd_offset; } pkt_t; /* @@ -216,7 +216,7 @@ process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd, static gboolean collate(pppdump_t*, FILE_T fh, int *err, gchar **err_info, guint8 *pd, int *num_bytes, direction_enum *direction, pkt_id *pid, - int num_bytes_to_skip); + gint64 num_bytes_to_skip); static void pppdump_close(wtap *wth); @@ -529,7 +529,7 @@ process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd, static gboolean collate(pppdump_t* state, FILE_T fh, int *err, gchar **err_info, guint8 *pd, int *num_bytes, direction_enum *direction, pkt_id *pid, - int num_bytes_to_skip) + gint64 num_bytes_to_skip) { int id; pkt_t *pkt = NULL; @@ -716,7 +716,7 @@ pppdump_seek_read(wtap *wth, direction_enum direction; pppdump_t *state; pkt_id *pid; - int num_bytes_to_skip; + gint64 num_bytes_to_skip; state = wth->capture.generic; diff --git a/wiretap/snoop.c b/wiretap/snoop.c index 57020a10ce..7862df5680 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -352,7 +352,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info) * Well, we have padding; how much? */ padbytes = g_ntohl(rec_hdr.rec_len) - - (sizeof rec_hdr + g_ntohl(rec_hdr.incl_len)); + ((guint)sizeof rec_hdr + g_ntohl(rec_hdr.incl_len)); /* * Is it at least the size of a Shomiti trailer? @@ -495,9 +495,9 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, /* * Don't count the pseudo-header as part of the packet. */ - rec_size -= sizeof (struct snoop_atm_hdr); - orig_size -= sizeof (struct snoop_atm_hdr); - packet_size -= sizeof (struct snoop_atm_hdr); + rec_size -= (guint32)sizeof (struct snoop_atm_hdr); + orig_size -= (guint32)sizeof (struct snoop_atm_hdr); + packet_size -= (guint32)sizeof (struct snoop_atm_hdr); wth->data_offset += sizeof (struct snoop_atm_hdr); break; @@ -531,9 +531,9 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, /* * Don't count the pseudo-header as part of the packet. */ - rec_size -= sizeof (shomiti_wireless_header); - orig_size -= sizeof (shomiti_wireless_header); - packet_size -= sizeof (shomiti_wireless_header); + rec_size -= (guint32)sizeof (shomiti_wireless_header); + orig_size -= (guint32)sizeof (shomiti_wireless_header); + packet_size -= (guint32)sizeof (shomiti_wireless_header); wth->data_offset += sizeof (shomiti_wireless_header); break; } @@ -575,7 +575,7 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, rec_size, packet_size); return FALSE; } - padbytes = rec_size - (sizeof hdr + packet_size); + padbytes = rec_size - ((guint)sizeof hdr + packet_size); while (padbytes != 0) { bytes_to_read = padbytes; if ((unsigned)bytes_to_read > sizeof padbuf) @@ -873,7 +873,7 @@ static gboolean snoop_dump(wtap_dumper *wdh, atm_hdrsize = 0; /* Record length = header length plus data length... */ - reclen = sizeof rec_hdr + phdr->caplen + atm_hdrsize; + reclen = (int)sizeof rec_hdr + phdr->caplen + atm_hdrsize; /* ... plus enough bytes to pad it to a 4-byte boundary. */ padlen = ((reclen + 3) & ~3) - reclen; diff --git a/wiretap/visual.c b/wiretap/visual.c index dee9cbf550..c43b34777a 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -494,7 +494,7 @@ static gboolean visual_seek_read (wtap *wth, gint64 seek_off, /* If ATM capture, need to skip over visual ATM packet header too */ if (wth->file_encap == WTAP_ENCAP_ATM_PDUS) { - header_size += sizeof(struct visual_atm_hdr); + header_size += (int)sizeof(struct visual_atm_hdr); } /* Seek to the packet header */ diff --git a/wiretap/vms.c b/wiretap/vms.c index 905405d32e..2a271753f9 100644 --- a/wiretap/vms.c +++ b/wiretap/vms.c @@ -523,7 +523,7 @@ parse_single_hex_dump_line(char* rec, guint8 *buf, long byte_offset, /* Get the byte_offset directly from the record */ s = rec; - value = strtoul(s + 45 + in_off, NULL, 16); + value = (int)strtoul(s + 45 + in_off, NULL, 16); /* XXX - error check? */ if (value != byte_offset) { return FALSE; |