• Show log

    Commit

  • Hash : c05790a8
    Author : Patrick Steinhardt
    Date : 2018-08-09T11:16:15

    smart_pkt: return parsed length via out-parameter
    
    The `parse_len` function currently directly returns the parsed length of
    a packet line or an error code in case there was an error. Instead,
    convert this to our usual style of using the return value as error code
    only and returning the actual value via an out-parameter. Thus, we can
    now convert the output parameter to an unsigned type, as the size of a
    packet cannot ever be negative.
    
    While at it, we also move the check whether the input buffer is long
    enough into `parse_len` itself. We don't really want to pass around
    potentially non-NUL-terminated buffers to functions without also passing
    along the length, as this is dangerous in the unlikely case where other
    callers for that function get added. Note that we need to make sure
    though to not mess with `GIT_EBUFS` error codes, as these indicate not
    an error to the caller but that he needs to fetch more data.