wireshark/epan/dfilter
Peter Wu 2f35a811a3 dfilter: fix memleak when using value_string values
When using a filter such as "ncp.alloc_reply_lvl2 == FALSE", a memory
leak would occur as follows:

 1. dfilter_fvalue_from_unparsed is called and
 2. ends up calling _uint64_from_unparsed
 3. which fails with error message "\"FALSE\" is not a valid number.".
 4. Next, mk_fvalue_from_val_string is called which maps "FALSE" to 0
 5. and the filter is successfully compiled.
 6. dfwork_free deliberately does not free the error message (since
    there should be none at this point) and we have a memleak (from 3).

Fix this memleak by clearing the error message when a successful
value_string mapping is found.

Change-Id: I78d59a4336342b09dc5448ea994b2e1d199d7f3f
Link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1302
Reviewed-on: https://code.wireshark.org/review/21497
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2017-05-04 18:56:10 +00:00
..
.editorconfig Add EditorConfig settings for most C files 2016-03-08 10:46:35 +00:00
CMakeLists.txt cmake: make WERROR_COMMON_FLAGS a normal string 2016-09-30 20:08:02 +00:00
dfilter-int.h Make the Flex scanners and YACC parser in libraries reentrant. 2016-04-03 22:21:29 +00:00
dfilter-macro.c dfilter-macro: add cleanup routine. 2017-02-03 02:38:20 +00:00
dfilter-macro.h dfilter-macro: add cleanup routine. 2017-02-03 02:38:20 +00:00
dfilter.c Rename routines to clarify what they do. 2017-04-12 04:56:49 +00:00
dfilter.h Qt: Add check for field extractors 2016-02-05 05:35:02 +00:00
dfunctions.c
dfunctions.h
dfvm.c Have fvalue_to_string_repr always return an (wmem) allocated buffer. 2016-05-10 22:49:08 +00:00
dfvm.h
drange.c
drange.h
gencode.c Fix checkAPI.pl warnings about printf 2016-07-25 04:26:50 +00:00
gencode.h
grammar.lemon Improve support for single-character fields and filter expressions. 2016-09-19 02:51:13 +00:00
Makefile.am Remove Makefile.common files 2016-06-30 11:04:17 +00:00
scanner.l Include config.h at the very beginning of all Flex scanners. 2016-12-02 21:02:10 +00:00
semcheck.c dfilter: fix memleak when using value_string values 2017-05-04 18:56:10 +00:00
semcheck.h
sttype-function.c
sttype-function.h
sttype-integer.c
sttype-pointer.c
sttype-range.c
sttype-range.h
sttype-set.c
sttype-set.h
sttype-string.c Improve support for single-character fields and filter expressions. 2016-09-19 02:51:13 +00:00
sttype-test.c
sttype-test.h
syntax-tree.c
syntax-tree.h Improve support for single-character fields and filter expressions. 2016-09-19 02:51:13 +00:00