[BUG] segmentation fault in git-diff
- From
Érico Rolim <erico.erc@gmail.com>
- Date
- Apr 9, 2020, 22:22 UTC
- Message-ID
- <CAFDeuWO+2JEGudtnHZvSsSUOVRR83U9ziLEjSoDyMWxYhvDMKg@mail.gmail.com>
Hey there!
I have found a bug in the git-diff utility, which is reproducible in the next branch. In any repository, if I run
git diff :/any/path/
(The important part is the trailing forward slash. No slash will generate either a valid diff or an error message about the path not being known. ":/" also works without issue)
it will trigger a SIGSEV. I have traced that back to the refs_read_raw_ref() function, where it seems the ref_store parameter passed to it is 0x0 (according to GDB). It's always possible to include a null-check in that function to fix the issue, but I don't think that'd be the best solution. I can attempt to fix it, but I don't know what (and where) the proper solution would be, because I don't know what the expected behavior is here, nor where exactly it should fail. Do you think this could also warrant the creation of a test?
I don't know what the best debug resources (valgrind output, core file from gdb) would be, but I can provide them if necessary.
Thanks,
Érico Nogueira