Skip to content

pr-git-2503/OphirBleicher/bug-difftool-v1

tagged this 22 Nov 13:39
From: Ophir Bleicher <ophirble@gmail.com>

Check the cache entry returned by make_transient_cache_entry() in
builtin/difftool.c. An invalid path can cause the function to
dereference a NULL pointer, resulting in a segmentation fault:

$ blob=$(printf '%s\n' DEADBLOB | git hash-object -w --stdin)
$ tree=$(printf "100644 blob %s\t.git\n" "$blob" | git mktree)
$ commit=$(git commit-tree -m BADCOMMIT "$tree")
$ git difftool --dir-diff --no-symlinks --extcmd true "$commit" HEAD
error: invalid path '.git'
Segmentation fault (core dumped) git difftool ...

Add a regression test in t/t7800-difftool.sh for a tree containing
an invalid .git path to ensure git difftool --dir-diff exits
correctly.

Signed-off-by: Ophir Bleicher <ophirble@gmail.com>

Submitted-As: https://lore.kernel.org/git/pull.2503.git.git.1795354765127.gitgitgadget@gmail.com
Assets 2
Loading