• Show log

    Commit

  • Hash : a9f1ca09
    Author : Patrick Steinhardt
    Date : 2018-08-09T11:01:00

    smart_pkt: fix buffer overflow when parsing "ok" packets
    
    There are two different buffer overflows present when parsing "ok"
    packets. First, we never verify whether the line already ends after
    "ok", but directly go ahead and also try to skip the expected space
    after "ok". Second, we then go ahead and use `strchr` to scan for the
    terminating newline character. But in case where the line isn't
    terminated correctly, this can overflow the line buffer.
    
    Fix the issues by using `git__prefixncmp` to check for the "ok " prefix
    and only checking for a trailing '\n' instead of using `memchr`. This
    also fixes the issue of us always requiring a trailing '\n'.
    
    Reported by oss-fuzz, issue 9749:
    
    Crash Type: Heap-buffer-overflow READ {*}
    Crash Address: 0x6310000389c0
    Crash State:
      ok_pkt
      git_pkt_parse_line
      git_smart__store_refs
    
    Sanitizer: address (ASAN)