Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-commits: [Wireshark-commits] master b3b1f7c: logcat: improve (crash) robustness, improve

From: Wireshark code review <code-review-do-not-reply@xxxxxxxxxxxxx>
Date: Fri, 11 Jul 2014 13:29:27 +0000 (UTC)
URL: https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=b3b1f7c3aa2233a147294bad833b748d38fba84d
Submitter: Michal Labedzki (michal.labedzki@xxxxxxxxx)
Changed: branch: master
Repository: wireshark

Commits:

b3b1f7c by Peter Wu (peter@xxxxxxxxxxxxx):

    logcat: improve (crash) robustness, improve names
    
    The logcat version detector would crash with ASAN enabled because it did
    not validate the payload length and hence a payload length of 0 would
    trigger out-of-bounds access. (This happened on non-logcat data.)
    
    This patch tries to get rid of all magic numbers by using a structure,
    improves the version detector to validate the payload length and
    prevents crashes due to missing nul-terminators in the input. Older
    Android kernels would create entries with __pad with random contents, so
    that cannot be used to determine version for v1. Instead, use heuristics
    on the priority, tag and maybe the msg field.
    
    Furthermore, Android is mostly (if not, always?) Little-Endian, so add
    conversions where necessary (just in case WS supports BE arches).
    
    "microseconds" has been renamed to "milliseconds" because that is what
    they are, actually. A duplicate logcat_log loop has been refactored
    such that one loop is sufficient, instead of separate buffers for each
    log part, a single one is now used. get_priority does not really need
    a pointer, just make it accept a character.
    
    The output has been validated against v1 and v2 logcat binary formats
    with __pad (hdr_size) equal to 0, and on attachment 9906.
    
    Change-Id: I46c8813e76fe705b293ffdee85b4c1bfff7d8362
    Reviewed-on: https://code.wireshark.org/review/2803
    Reviewed-by: Michal Labedzki <michal.labedzki@xxxxxxxxx>
    Tested-by: Michal Labedzki <michal.labedzki@xxxxxxxxx>
    

Actions performed:

    from  aa0eb59   Restore some assignments of ti2 that were removed in the proto_tree_add_subtree[_format] conversion
    adds  b3b1f7c   logcat: improve (crash) robustness, improve names


Summary of changes:
 wiretap/logcat.c |  269 +++++++++++++++++++++++++++++++++---------------------
 1 file changed, 167 insertions(+), 102 deletions(-)