Commit Graph

21 Commits

Author SHA1 Message Date
Guy Harris 1158576622 Don't pick up junk from an unset error-number variable.
Keep the actual error code and pointer-to-error-string in the scanner
state, rather than pointers to the variables passed in to us.
Initialize them to 0 and NULL, respectively.

That way, when the actual scanner routine returns, we don't check for an
error by looking at the error variable pointed to by our argument, which
might not have been set by the scanner and might have stack junk in it,
we look at a structure member we set to 0 before the scan.

Change-Id: I81a4fd6d5cf5e56f5638fae1253c48dc50c9c36d
Reviewed-on: https://code.wireshark.org/review/17721
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-16 01:32:47 +00:00
Guy Harris 3ba8a28f50 Just return the value of yyparse() from run_ascend_parser().
That's what we're doing already, but get rid of the variable to which we
assigned the return value.

Change-Id: I55e31664bc26bbfffe4a4ca764c917eefbb9a8f1
Reviewed-on: https://code.wireshark.org/review/17126
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-18 01:35:25 +00:00
Guy Harris 72a3195c86 The caplen for a packet is always "number of bytes seen".
Set wirelen to the length from the header, but don't set caplen; start
caplen out as 0 and count it up whenever we add a byte.

Bug: 12754
Change-Id: Ib4e45e947df6077f97a423157c152dac9f57734a
Reviewed-on: https://code.wireshark.org/review/17120
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-17 23:05:27 +00:00
Guy Harris 368e3b8bd7 Set the extra type the right way.
Use %option extra_type= rather than #defining YY_EXTRA_TYPE.

Change comments to reflect that the state structure is used both by the
lexical analyzer and the parser.

Change-Id: I19a81de61cbd6e86d71154f376ef0681cc6d42fb
Reviewed-on: https://code.wireshark.org/review/14826
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-05 23:32:18 +00:00
Guy Harris 59816ef00c Make the Flex scanners and YACC parser in libraries reentrant.
master-branch libpcap now generates a reentrant Flex scanner and
Bison/Berkeley YACC parser for capture filter expressions, so it
requires versions of Flex and Bison/Berkeley YACC that support that.

We might as well do the same.  For libwiretap, it means we could
actually have multiple K12 text or Ascend/Lucent text files open at the
same time.  For libwireshark, it might not be as useful, as we only read
configuration files at startup (which should only happen once, in one
thread) or on demand (in which case, if we ever support multiple threads
running libwireshark, we'd need a mutex to ensure that only one file
reads it), but it's still the right thing to do.

We also require a version of Flex that can write out a header file, so
we change the runlex script to generate the header file ourselves. This
means we require a version of Flex new enough to support --header-file.

Clean up some other stuff encountered in the process.

Change-Id: Id23078c6acea549a52fc687779bb55d715b55c16
Reviewed-on: https://code.wireshark.org/review/14719
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-03 22:21:29 +00:00
Guy Harris f520f82750 Get rid of a bunch of unused variables.
("Unused" includes "set but not used".)

Change-Id: Id67859b366e8caa50262f8530630ec4e8ef1507a
Reviewed-on: https://code.wireshark.org/review/12457
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-06 23:40:08 +00:00
Guy Harris 9d52712ed8 More unnecessary <stdio.h> includes.
libwiretap no longer uses standard I/O routines to read files; those
includes are left over from when it did.

Change-Id: Ia46c5e24ed25c6bd254cd271746ace539a37e590
Reviewed-on: https://code.wireshark.org/review/11634
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-08 01:26:49 +00:00
Guy Harris 0734ac385f Rename buffer_ routines to ws_buffer_ to avoid name collisions.
In particular, epan/wslua/lrexlib.c has its own buffer_ routines,
causing some linker warnings on some platforms, as reported in bug
10332.

(Not to be backported to 1.12, as that would change the API and ABI of
libwsutil and libwiretap.  We should also make the buffer_ routines in
epan/wslua/lrexlib.c static, which should also address this problem, but
the name change avoids other potential namespace collisions.)

Change-Id: I1d42c7d1778c7e4c019deb2608d476c52001ce28
Reviewed-on: https://code.wireshark.org/review/3351
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-08-02 11:01:29 +00:00
Guy Harris d4dab16a3f Only one buffer.c, please.
Otherwise, if you link with both libwiretap and libfiletap, it's
anybody's guess which one you get.  That means you're wasting memory
with two copies of its routines if they're identical, and means
surprising behavior if they're not (which showed up when I was debugging
a double-free crash - fixing libwiretap's buffer_free() didn't fix the
problem, because Wireshark happened to be calling libfiletap' unfixed
buffer_free()).

There's nothing *tap-specific about Buffers, anyway, so it really
belongs in wsutil.

Change-Id: I91537e46917e91277981f8f3365a2c0873152870
Reviewed-on: https://code.wireshark.org/review/3066
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-15 23:43:32 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Edwin Groothuis 05f54f7d6a Fix build on FreeBSD 10.0
Change-Id: I6be0d2dfe3b44f166233b1dd20ef02c10a024f97
Reviewed-on: https://code.wireshark.org/review/74
Reviewed-by: Evan Huus <eapache@gmail.com>
Tested-by: Evan Huus <eapache@gmail.com>
2014-02-02 00:18:59 +00:00
Guy Harris 8c9edf1280 Have the seek-read routines take a Buffer rather than a guint8 pointer
as the "where to put the packet data" argument.

This lets more of the libwiretap code be common between the read and
seek-read code paths, and also allows for more flexibility in the "fill
in the data" path - we can expand the buffer as needed in both cases.

svn path=/trunk/; revision=49949
2013-06-16 00:20:00 +00:00
Guy Harris 887c604334 Hoist a bunch of common code between ascend_read() and
ascend_seek_read() into parse_ascend().

Adjust the buffer size *before* attempting to fill it up.

svn path=/trunk/; revision=49343
2013-05-16 21:04:41 +00:00
Guy Harris 78ee09dfeb Get rid of unused global variable.
svn path=/trunk/; revision=49341
2013-05-16 20:25:44 +00:00
Jeff Morriss 3729335973 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45016
2012-09-20 01:48:30 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Gerald Combs 88ae29c149 Use "%parse-param" instead of a global variable. Fixes a scan-build
warning.

svn path=/trunk/; revision=42578
2012-05-11 17:15:12 +00:00
Bill Meier bf4844eb99 Fix some gcc 'old-style function definition' warnings.
svn path=/trunk/; revision=37482
2011-05-31 15:49:59 +00:00
Guy Harris 207a75388a Have parse_ascend() return:
PARSED_RECORD if we got a packet;

    PARSED_NONRECORD if the parser succeeded but didn't see a packet;

    PARSE_FAILED if the parser failed.

Treat anything other than PARSED_RECORD as a failure, for now; I'm not
sure why we were treating "parser succeeded but didn't see a packet" as
success, as that was causing us to recognize some non-Ascend-output text
files as Ascend files and to return "records" with bogus caplen and len
values.

svn path=/trunk/; revision=32009
2010-02-25 20:45:59 +00:00
Gerald Combs f7d80a113c From Ben Winslow via bug 3535:
Because Lucent/Ascend equipment will sometimes omit the hex dump for a packet
or send two headers followed by two hex dumps, Wireshark needs to be very
lenient when parsing a Lucent/Ascend trace.  On a busy access server, a packet
like this is pretty likely to appear within a few minutes.

svn path=/trunk/; revision=28749
2009-06-15 22:25:05 +00:00
Jörg Mayer 0d300bb6f5 Rename all of the ascend files:
That way we hopefully won't need the runlex.sh hack any
more. Also the ylwrap stuff is (hopefully) obsolete.

ascend.[hc]      -> ascendtext.[hc]
ascend-scanner.l -> ascend_scanner.l
ascend-grammar.y -> ascend.y


svn path=/trunk/; revision=28744
2009-06-15 18:56:46 +00:00