Commit Graph

115 Commits

Author SHA1 Message Date
João Valverde d0a91b27f2 plugins: config.h must not be included by public headers
For a sane plugin build environment. Include config.h as the first
header in the .c file instead.

Fix by moving required compiler attribute macros to a new
"ws_attributes.h" API header.

Change-Id: I34f58a927f68c1a0e59686c14d214825149749e1
Reviewed-on: https://code.wireshark.org/review/23400
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2017-09-06 08:10:56 +00:00
Alexis La Goutte dcba264a46 lemon: avoid redundant redeclaration of ‘memory_error’ [-Wredundant-decls]
Change-Id: I1fbc11dc433363b659ddba9a77e52ffd4e3968d7
Reviewed-on: https://code.wireshark.org/review/21850
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-05-31 11:33:19 +00:00
Alexis La Goutte 427c800a9f lemon: fix no previous prototype for ‘memory_error’ [-Wmissing-prototypes]
Change-Id: I5830581c843af41f48bc9645c2be7cf35fa00391
Reviewed-on: https://code.wireshark.org/review/21463
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-05-02 17:38:53 +00:00
Alexis La Goutte 9ccba0e605 Revert "Make the set of static routines match that in the current tip SQLite."
This reverts commit 96c72df2df.

Generated a lot of warning (-Wmissing-prototypes)
and i try to kept a sync branch on https://github.com/alagoutte/sqlite/tree/wireshark

Change-Id: I42252a6e736f96783a9fa9805b84e525fe11726e
Reviewed-on: https://code.wireshark.org/review/21182
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2017-04-24 07:30:05 +00:00
Guy Harris 96c72df2df Make the set of static routines match that in the current tip SQLite.
This reduces the differences between our lemon.c and SQLite's.

Change-Id: Ie672fa564a43ffe2fae271968accfed2a864bb63
Reviewed-on: https://code.wireshark.org/review/21107
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-15 05:07:57 +00:00
Guy Harris d523f615be Make memory_error() a routine.
That makes the code more like Lemon as distributed.

Note that Lemon, as distributed, at least claims to have a bunch of
stuff "From the file "XXX.{c,h}", which might be the result of lemon.c
being an "amalgamation":

	https://www.sqlite.org/amalgamation.html

although, unlike SQLite, the individual bits of the amalgamation don't
appear to be present in the SQLite Fossil repository, so maybe they've
been permanently glued together.

Change-Id: I361d0d16be0744b127110d7d237fdd84e30b6432
Reviewed-on: https://code.wireshark.org/review/21105
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-15 02:33:52 +00:00
Guy Harris 3bd7671083 Make whitespace match what's checked into the SQLite repository.
They accepted some of our changes, but with no space between "struct
XXX" and "*.  Whatever.

Change-Id: I6b29462dc8b04ebf0822f8512d82f5f8df575447
Reviewed-on: https://code.wireshark.org/review/21101
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-15 01:29:11 +00:00
Alexis La Goutte 867d5cd6b1 lemon: fix this statement may fall through [-Werror=implicit-fallthrough=] found by gcc7
Change-Id: If52bc0092f1baa833e35a9f4c107faf72c3b64d1
Reviewed-on: https://code.wireshark.org/review/20392
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-05 15:14:39 +00:00
Alexis La Goutte a76c6cfa42 lemon: Fix Dereference of null pointer found by Clang analyzer
lemon.c:877:10: warning: Access to field 'lhs' results in a dereference of a null pointer (loaded from field 'startRule')
lemon.c:1141:22: warning: Access to field 'lhs' results in a dereference of a null pointer (loaded from field 'startRule')

it is false positve lem.nrule==0 implies lem.rule==NULL

Change-Id: Id63086990762fbf5195bce34a28f25aeb7a246f7
Reviewed-on: https://code.wireshark.org/review/19445
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-12-30 00:56:18 +00:00
Alexis La Goutte 60551ea55a Lemon: resync with upstream
lemon: Tue Aug 16 16:46:40 2016
lempar: Tue Dec 6 17:59:05 2016 +0000

a copy of all Wireshark changes are available https://github.com/alagoutte/sqlite/tree/wireshark

Change-Id: I144d0f983e4ac960b5a7a2fd8cd379f6282579f8
Reviewed-on: https://code.wireshark.org/review/15987
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-12-24 19:35:59 +00:00
Martin Kaiser c26968434c lemon: use a define for fseek()'s whence parameter
for people who don't immediately understand what fseek(fp, 0, 2) does

Change-Id: I297ba6fd718ef0f09c4d0b29bf433262c3c38435
Reviewed-on: https://code.wireshark.org/review/15976
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-06-16 19:57:15 +00:00
Guy Harris 38d39f292e Have MemoryCheck() directly incorporate the error message and exit.
Manually inline memory_error() in MemoryCheck(), so that static
analyzers know that, if MemoryCheck() sees a null pointer, it exists,
and the null pointer isn't subsequently used.

Use MemoryCheck() instead of the one place where we manually checked for
a null pointer and called memory_error().

Change-Id: Id6b0328cfd17cb14ec9d1e461420896a31573c71
Reviewed-on: https://code.wireshark.org/review/15851
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-06-12 19:18:41 +00:00
Guy Harris 7bbc60c668 Add more memory checks, and use MemoryCheck() for some existing checks.
Always check for malloc() and realloc() failing.  Use MemoryCheck() for
most of the checks - it's a bit cleaner and makes the error message the
same for those checks.

Change-Id: I533153c697b37b85adfa0259c1352efece0b0486
Reviewed-on: https://code.wireshark.org/review/15849
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-06-12 17:34:47 +00:00
Dario Lombardo 2bf715dcc2 lemon: fix leak.
Found by clang's ccc-analyzer.

Change-Id: I04eaad73486a43a77c4f08cf519bbfe7d2d8c838
Reviewed-on: https://code.wireshark.org/review/13581
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-01-31 13:27:25 +00:00
Alexis La Goutte e63fd927f9 lemon (tools): Fix Dereference of null pointer found by Clang analyzer
Change-Id: Ica08d9372fbe3809eb078e0285cba2a49cee6b8d
Reviewed-on: https://code.wireshark.org/review/13331
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-01-22 19:36:37 +00:00
Alexis La Goutte 9a09f36807 Lemon: resync with upstream
lemon: Thu Oct 29 13:48:15 2015
lempar: Tue Nov 10 14:51:22 2015

a copy of all Wireshark changes are available https://github.com/alagoutte/sqlite/tree/wireshark

Change-Id: I51f8b40a7087362502f6ce2156820a9f107ddf15
Reviewed-on: https://code.wireshark.org/review/13033
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-01-12 05:42:57 +00:00
João Valverde cac0ab63ee lemon: Fix warnings [-Wpedantic]
Change-Id: I7b350b2c4de5f86de24c8f2309016f3de7af8516
Reviewed-on: https://code.wireshark.org/review/12959
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-01-07 15:52:24 +00:00
João Valverde 2bc6530a99 lemon: Fix warnings [-Wcast-qual]
Change-Id: I2b9efa50cf6385622601d2a80f4cc51691d080a1
Reviewed-on: https://code.wireshark.org/review/12960
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-31 20:13:28 +00:00
Alexis La Goutte e0af790aac lemon (tools): Fix Dereference of null pointer found by Clang analyzer
Change-Id: I6be51833b4268dbfde5c78820004a4714779b0c5
Reviewed-on: https://code.wireshark.org/review/9515
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2015-11-23 09:32:38 +00:00
Guy Harris ad52d7d83a Bail out immediately if we can't allocate a buffer for carving up $PATH.
Quit immediately, don't even bother allocating a buffer for the pathname
of the file we found.

Revert some other cosmetic changes, to reduce the differences between us
and upstream.

Change-Id: I217fecee64c7e6bac9272486d0cc334e192b501e
Reviewed-on: https://code.wireshark.org/review/11253
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-10-25 02:02:16 +00:00
Dario Lombardo 2d2b129493 lemon: move free() to avoid mem leak (CID 718529)
Change-Id: I3b0740f5ccc3b9b87ed351e26f198152bbb1e599
Reviewed-on: https://code.wireshark.org/review/10801
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-10-25 00:21:48 +00:00
Dario Lombardo 24b5300411 lemon: add free() to avoid mem leak (CID 1309088)
Change-Id: Id32864d324f72ffee9c1033f0f36a79eb2651334
Reviewed-on: https://code.wireshark.org/review/10797
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-10-24 16:48:09 +00:00
Alexis La Goutte 3ea89e6155 lemon (tools): Fix Dead Store (Dead assignement/Dead increment) warning found by Clang
Change-Id: Ibfa0bfd589e77a58b7b242c7c2fe25ef052a874e
Reviewed-on: https://code.wireshark.org/review/9516
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2015-07-25 18:07:34 +00:00
AndersBroman 88302f267c Try to fix OSX build boot
lemon.c:1784: warning: implicit conversion shortens 64-bit value into a 32-bit value
lemon.c:1790: warning: implicit conversion shortens 64-bit value into a 32-bit value
1790: warning: implicit conversion shortens 64-bit value into a 32-bit value
1928: warning: implicit conversion shortens 64-bit value into a 32-bit value
2707: warning: implicit conversion shortens 64-bit value into a 32-bit value

Change-Id: Ief1b64009891de6885c2c9a6cb0e290752de889f
Reviewed-on: https://code.wireshark.org/review/9463
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-07-02 11:09:36 +00:00
Alexis La Goutte 9d8b810127 Lemon: Update lemon tools
Update from SQLite trunk (19 April 2015)

Add include <config.h>

Fix warning: unused parameter 'argc' [-Wunused-parameter] (using _U_)

Fix implicit conversion loses integer precision

Fix comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]

Fix function declaration isn’t a prototype [-Wstrict-prototypes]

Fix warning: old-style function definition [-Wold-style-definition]

Fix trailing whitespace

Fix use -T for template for epan\Makefile.nmake, epan\dfilter\Makefile.nmake, plugins\mate\Makefile.nmake, plugins\tpg\Makefile.nmake and cmake/modules/UseLemon.cmake

Fix -Wmissing-prototypes Remove unused function (acttab_free)

Add basename the filename with only filename (no path...)

Fix lemon.c:3435: warning: implicit conversion shortens 64-bit value into a 32-bit value

Add "new" version of lempar.c (3 November 2009).

LEMPAR: fix trailing whitespace

LEMPAR: fix -Wunused-parameter

Change-Id: I2df7e39c9a6846de26743a981fb76aca423fe813
Reviewed-on: https://code.wireshark.org/review/6502
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-07-02 08:49:02 +00:00
Pascal Quantin 7d004dc887 Revert "Lemon: Update lemon tools"
This reverts commit 5855dd8d53.

This Lemon update fails to compile on OSX and triggers asserts on other platforms

Change-Id: I12a8a2bf32db31e5a9b0cb1a67a39724e30f3e91
Reviewed-on: https://code.wireshark.org/review/6496
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-01-11 19:57:45 +00:00
Alexis La Goutte 5855dd8d53 Lemon: Update lemon tools
Fix warning: declaration shadows a variable in the global scope [-Wshadow]

Add include <config.h>

Fix warning: unused parameter 'argc' [-Wunused-parameter] (using _U_)

Fix implicit conversion loses integer precision

Fix comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]

Fix function declaration isn’t a prototype [-Wstrict-prototypes]

Fix warning: old-style function definition [-Wold-style-definition]

Fix trailing whitespace

Fix use -T for template for epan\Makefile.nmake, epan\dfilter\Makefile.nmake, plugins\mate\Makefile.nmake, plugins\tpg\Makefile.nmake and cmake/modules/UseLemon.cmake

Fix -Wmissing-prototypes

Remove unused function (acttab_free)

Add basename the filename with only filename (no path...)

Change-Id: Ia79f61e29f828575df61cc89134c6c553044e86d
Reviewed-on: https://code.wireshark.org/review/3976
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2015-01-11 18:56:08 +00:00
Alexis La Goutte d8001e8064 Continue to remove $Id$ from top of file
(Using sed : sed -i '/^\*\* \$Id\$/,+1 d') (2 star and space)

Change-Id: I48505ffb8bfa103cd7db0117e18cdb1925a7034d
Reviewed-on: https://code.wireshark.org/review/884
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-31 18:50:19 +00:00
Jörg Mayer a8002aa0b7 Fix two coverity messages:
*** CID 718534:  Dereference before null check  (REVERSE_INULL)
/tools/lemon/lemon.c: 3425 in translate_code()
3419                rp->rhs[i]->index,i-rp->nrhs+1);
3420           }else{
3421             /* No destructor defined for this term */
3422           }
3423         }
3424       }
>>>     CID 718534:  Dereference before null check  (REVERSE_INULL)
>>>     Null-checking "rp->code" suggests that it may be null, but it has already been
+dereferenced on all paths leading to the check.
3425       if( rp->code ){
3426         cp = append_str(0,0,0,0);
3427         rp->code = Strsafe(cp?cp:"");
3428       }
3429     }
3430

*** CID 1156989:  Out-of-bounds read  (OVERRUN)
/tools/lemon/lemon.c: 3139 in tplt_xfer()
3133       int i, iStart;
3134       char line[LINESIZE];
3135       while( fgets(line,LINESIZE,in) && (line[0]!='%' || line[1]!='%') ){
3136         (*lineno)++;
3137         iStart = 0;
3138         if( name ){
>>>     CID 1156989:  Out-of-bounds read  (OVERRUN)
>>>     Overrunning array "line" of 1000 bytes at byte offset 1000 using index "i"
+(which evaluates to 1000).
3139           for(i=0; line[i] && i<LINESIZE; i++){
3140             if( line[i]=='P' && i<(LINESIZE-5) && strncmp(&line[i],"Parse",5)==0
3141               && (i==0 || !safe_isalpha(line[i-1]))
3142             ){
3143               if( i>iStart ) fprintf(out,"%.*s",i-iStart,&line[iStart]);
3144               fprintf(out,"%s",name);

svn path=/trunk/; revision=54849
2014-01-19 17:59:20 +00:00
Guy Harris 61d5c458a0 Squelch some warnings.
svn path=/trunk/; revision=54711
2014-01-13 19:07:48 +00:00
Balint Reczey 2ec033d15e Fix potential signed int overflow in Lemon
This chrashed Solaris buildbot when -ftrapv was enabled.
Triaged by Guy Harris, see detail at:
http://www.wireshark.org/lists/wireshark-dev/201311/msg00185.html

svn path=/trunk/; revision=53624
2013-11-28 16:04:33 +00:00
Evan Huus 2322bd3122 Fix lemon FSF address and add license exception for the generated mate grammar
files. One of them has no license (it is just defines) and the other gets picked
up as LGPL for no reason I can discern.

svn path=/trunk/; revision=52675
2013-10-18 18:10:46 +00:00
Chris Maynard 83b4b73dd1 Fix Coverity CID 280323 (Free of array-typed value) by ensuring that tpltname doesn't point to the buf[] stack array before attempting to free it.
#BACKPORT(1.10)

svn path=/trunk/; revision=50335
2013-07-03 01:47:18 +00:00
Gerald Combs 62d87b6cad tools/lemon/lemon.c: Fix an integer shortening issue. (CMake enables
-Werror here but Autotools doesn't. Which is correct?)

epan/dissectors/dcerpc: idl2wrs isn't an installed executable in
Autotools so don't make it one in CMake.

svn path=/trunk/; revision=49871
2013-06-10 18:55:03 +00:00
Anders Broman 3dc702e2a8 Align a bit more with upstream.
svn path=/trunk/; revision=48559
2013-03-26 05:36:27 +00:00
Anders Broman 41d6d12497 Rearrang the code to align with sqlite lemon and copy over a few more things.
svn path=/trunk/; revision=48014
2013-03-02 19:34:50 +00:00
Anders Broman bd2b6b9964 Wite space changes.
svn path=/trunk/; revision=48005
2013-03-02 12:09:50 +00:00
Anders Broman b9cb9968f2 lemon.c:3176:8: error: attempt to free a non-heap object ‘buf’
svn path=/trunk/; revision=48003
2013-03-02 11:32:25 +00:00
Anders Broman 310b495ff3 Becport more code.
svn path=/trunk/; revision=48002
2013-03-02 10:56:17 +00:00
Anders Broman ad1ec109ed Missed one place.
svn path=/trunk/; revision=48001
2013-03-02 10:03:43 +00:00
Anders Broman da070427d9 lemon.c:78:14: note: expected ‘int (*)(const void *, const void *)’ but argument is of type ‘int (*)(const char *, const char *)’
svn path=/trunk/; revision=48000
2013-03-02 09:54:52 +00:00
Anders Broman 99d88bd54b More backports from sqlite lemon to try to address warnings.
svn path=/trunk/; revision=47998
2013-03-02 09:04:52 +00:00
Anders Broman 7c3a122e37 lemon.c:4628:5: error: conflicting types for ‘Configcmp’
lemon.c:366:5: note: previous declaration of ‘Configcmp’ was here

svn path=/trunk/; revision=47997
2013-03-02 08:40:49 +00:00
Anders Broman 18c724b0ad More backports from sqlite lemon to try to address warnings.
svn path=/trunk/; revision=47996
2013-03-02 08:19:31 +00:00
Anders Broman a5c53e847e Backports from sqlite lemon.
svn path=/trunk/; revision=47993
2013-03-01 23:54:06 +00:00
Jeff Morriss 0b8d70bfb7 Fix a cut-n-pasteo and add a const cast to quiet a warning.
svn path=/trunk/; revision=47991
2013-03-01 22:58:23 +00:00
Anders Broman ea76d02cb2 Backport const casts from sqlite lemon.
svn path=/trunk/; revision=47989
2013-03-01 21:37:48 +00:00
Anders Broman 44993045a2 try to remove C++ incompatibilities from lemon
svn path=/trunk/; revision=47987
2013-03-01 20:32:20 +00:00
Guy Harris eb769ce13e Clean up some warnings (including warnings that ultimately come from
trying to modify string constants, which isn't necessarily guaranteed to
work).

svn path=/trunk/; revision=47618
2013-02-10 22:09:21 +00:00
Guy Harris fbe74322b1 From Bill Parker:
Add some additional memory-allocation failure checks in Lemon.

	Use NULL rather than 0 as the null-pointer constant in those
	checks.

From me:

	Catch one more of the NULL-vs-0 cases.

	Fix some failure messages to use fprintf(stderr, ...) -
	ErrorMsg() requires a file name and line number, and is
	generally used if you're going to continue rather than just give
	up.

svn path=/trunk/; revision=45214
2012-09-29 19:40:27 +00:00