• Show log

    Commit

  • Hash : ea19efc1
    Author : Patrick Steinhardt
    Date : 2018-10-18T15:08:56

    util: fix out of bounds read in error message
    
    When an integer that is parsed with `git__strntol32` is too big to fit
    into an int32, we will generate an error message that includes the
    actual string that failed to parse. This does not acknowledge the fact
    that the string may either not be NUL terminated or alternative include
    additional characters after the number that is to be parsed. We may thus
    end up printing characters into the buffer that aren't the number or,
    worse, read out of bounds.
    
    Fix the issue by utilizing the `endptr` that was set by
    `git__strntol64`. This pointer is guaranteed to be set to the first
    character following the number, and we can thus use it to compute the
    width of the number that shall be printed. Create a test to verify that
    we correctly truncate the number.