Wireshark-commits: [Wireshark-commits] lts-1.12.1 22c2210: logcat: improve (crash) robustness, impr

From: Wireshark code review <code-review-do-not-reply@xxxxxxxxxxxxx>
Date: Sun, 31 May 2015 18:42:39 +0000 (UTC)
URL: https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=22c2210cc254cc6251c3831cd2b58f1ffe6a0cf8
Submitter: Balint Reczey (balint@xxxxxxxxxxxxxxx)
Changed: branch: lts-1.12.1
Repository: wireshark

Commits:

22c2210 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.
    
    Reviewed-on: https://code.wireshark.org/review/2803
    Reviewed-by: Michal Labedzki <michal.labedzki@xxxxxxxxx>
    Tested-by: Michal Labedzki <michal.labedzki@xxxxxxxxx>
    (cherry picked from commit b3b1f7c3aa2233a147294bad833b748d38fba84d)
    
    Conflicts:
    	wiretap/logcat.c
    
    Change-Id: I33bb20b5f9a5e03a231121a784bfffdfba0aba98
    Reviewed-on: https://code.wireshark.org/review/8346
    Reviewed-by: Gerald Combs <gerald@xxxxxxxxxxxxx>
    (cherry picked from commit afeff4f5d0c51d2394f7c0f00ae1c57ad8cd1ded)
    Reviewed-on: https://code.wireshark.org/review/8641
    Reviewed-by: Balint Reczey <balint@xxxxxxxxxxxxxxx>
    

Actions performed:

    from  8d6196c   Logcat: Fix dump formats
    adds  22c2210   logcat: improve (crash) robustness, improve names


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