In wiretap, set err to 0 before doing anything inside wtap_loop().

Tethereal was dying on me because err was initialized to some random value.

It was this section of code that would exit even if wtap_loop was successful
(returned TRUE) because err was never initialized or set to anything.

err = load_cap_file(&cf, out_file_type);
if (err != 0) {
       dissect_cleanup();
       exit(2);
}

<BIGGER sheepish grin>
Fixed even more errors in LLC dissector. I had inadvertantly used the
wrong tvbuff_t* when calling dissect_data_tvb(). There is no way we are going
to be successful in this tvbuff conversion w/o regression testing. I'm
working on setting up a simple Makefile for regression testing tonight.
That's why I'm finding so many bugs in my LLC conversion.
</BIGGER sheepish grin>

svn path=/trunk/; revision=1946
This commit is contained in:
Gilbert Ramirez 2000-05-12 05:06:33 +00:00
parent 742cb69433
commit 4ec50578de
2 changed files with 11 additions and 8 deletions

View File

@ -2,7 +2,7 @@
* Routines for IEEE 802.2 LLC layer
* Gilbert Ramirez <gram@xiexie.org>
*
* $Id: packet-llc.c,v 1.58 2000/05/12 04:21:21 gram Exp $
* $Id: packet-llc.c,v 1.59 2000/05/12 05:06:26 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -395,11 +395,11 @@ dissect_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
break;
default:
dissect_data_tvb(tvb, pinfo, tree);
dissect_data_tvb(next_tvb, pinfo, tree);
break;
}
} else
dissect_data_tvb(tvb, pinfo, tree);
dissect_data_tvb(next_tvb, pinfo, tree);
break;
case OUI_CABLE_BPDU: /* DOCSIS cable modem spanning tree BPDU */
@ -415,7 +415,7 @@ dissect_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_item(llc_tree,
hf_llc_pid, tvb, 6, 2, etype);
}
dissect_data_tvb(tvb, pinfo, tree);
dissect_data_tvb(next_tvb, pinfo, tree);
break;
}
}
@ -432,6 +432,7 @@ dissect_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
);
}
next_tvb = tvb_new_subset(tvb, llc_header_len, -1);
if (XDLC_IS_INFORMATION(control)) {
tvb_compat(tvb, &pd, &offset);
/* non-SNAP */
@ -440,11 +441,10 @@ dissect_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* do lookup with the subdissector table */
if (!dissector_try_port(subdissector_table, dsap,
pd, offset, pinfo->fd, tree)) {
dissect_data_tvb(tvb, pinfo, tree);
dissect_data_tvb(next_tvb, pinfo, tree);
}
} else {
next_tvb = tvb_new_subset(tvb, llc_header_len, -1);
dissect_data_tvb(tvb, pinfo, tree);
dissect_data_tvb(next_tvb, pinfo, tree);
}
}
}

View File

@ -1,6 +1,6 @@
/* wtap.c
*
* $Id: wtap.c,v 1.39 2000/04/08 00:33:04 sharpe Exp $
* $Id: wtap.c,v 1.40 2000/05/12 05:06:33 gram Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@ -212,6 +212,9 @@ int wtap_loop(wtap *wth, int count, wtap_handler callback, u_char* user,
{
int data_offset, loop = 0;
/* Start be clearing error flag */
*err = 0;
while ((data_offset = wth->subtype_read(wth, err)) > 0) {
callback(user, &wth->phdr, data_offset,
buffer_start_ptr(wth->frame_buffer));