• J
    avoid segfault when reading header of malformed commits · a9c7a8a8
    Jeff King 提交于
    If a commit object has a header line at the end of the
    buffer that is missing its newline (or if it appears so
    because the content on the header line contains a stray
    NUL), then git will segfault.
    
    Interestingly, this case is explicitly handled and we do
    correctly scan the final line for the header we are looking
    for. But if we don't find it, we will dereference NULL while
    trying to look at the next line.
    
    Git will never generate such a commit, but it's good to be
    defensive. We could die() in such a case, but since it's
    easy enough to handle it gracefully, let's just issue a
    warning and continue (so you could still view such a commit
    with "git show", though you might be missing headers after
    the NUL).
    Signed-off-by: NJeff King <peff@peff.net>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    a9c7a8a8
pretty.c 34.9 KB