]> git.ipfire.org Git - thirdparty/git.git/commit - run-command.c
run-command: mark path lookup errors with ENOENT
authorJeff King <peff@peff.net>
Wed, 24 Oct 2018 07:38:00 +0000 (03:38 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Oct 2018 02:06:51 +0000 (11:06 +0900)
commit321fd82389742398d2924640ce3a61791fd27d60
tree912f515f765b3fe082c8f4e4b6a941b87990282e
parentd0832b2847aa9669c09397c5639d7fe56abaf9fc
run-command: mark path lookup errors with ENOENT

Since commit e3a434468f (run-command: use the
async-signal-safe execv instead of execvp, 2017-04-19),
prepare_cmd() does its own PATH lookup for any commands we
run (on non-Windows platforms).

However, its logic does not match the old execvp call when
we fail to find a matching entry in the PATH. Instead of
feeding the name directly to execv, execvp would consider
that an ENOENT error. By continuing and passing the name
directly to execv, we effectively behave as if "." was
included at the end of the PATH. This can have confusing and
even dangerous results.

The fix itself is pretty straight-forward. There's a new
test in t0061 to cover this explicitly, and I've also added
a duplicate of the ENOENT test to ensure that we return the
correct errno for this case.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
run-command.c
t/t0061-run-command.sh