[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Misleading error when attempting to run foreign executable
From: |
Eli Schwartz |
Subject: |
Re: Misleading error when attempting to run foreign executable |
Date: |
Sun, 10 Oct 2021 21:09:53 -0400 |
On 10/10/21 20:24, Dmitry Goncharov via Bug reports for the GNU Bourne
Again SHell wrote:
> On Sun, Oct 10, 2021 at 7:52 PM Ángel <angel@16bits.net> wrote:
>> Looking at the code, it doesn't even need an extra stat(), it already
>> knows the file exists
>
> Attempts to know ahead of time or check afterwards that the file
> exists are subject to a race condition.
Immediately above the patch diff you are responding to, is:
#if defined (HAVE_HASH_BANG_EXEC)
READ_SAMPLE_BUF (command, sample, sample_len);
if (sample_len > 0)
sample[sample_len - 1] = '\0';
if (sample_len > 2 && sample[0] == '#' && sample[1] == '!')
{
char *interp;
int ilen;
interp = getinterp (sample, sample_len, (int *)NULL);
ilen = strlen (interp);
errno = i;
if (interp[ilen - 1] == '\r')
{
interp = xrealloc (interp, ilen + 2);
interp[ilen - 1] = '^';
interp[ilen] = 'M';
interp[ilen + 1] = '\0';
}
sys_error (_("%s: %s: bad interpreter"), command, interp ? interp
: "");
FREE (interp);
return (EX_NOEXEC);
}
#endif
So I wonder, if bash already in this exact case attempts to open() the
file and read() it to look for a shebang, what's the harm in assuming
(or checking) that it exists in this patch?
--
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User
OpenPGP_signature
Description: OpenPGP digital signature
- Misleading error when attempting to run foreign executable, Andrea Monaco, 2021/10/03
- Re: Misleading error when attempting to run foreign executable, Alex fxmbsw7 Ratchev, 2021/10/03
- Re: Misleading error when attempting to run foreign executable, Chet Ramey, 2021/10/04
- Re: Misleading error when attempting to run foreign executable, Ilkka Virta, 2021/10/04
- Re: Misleading error when attempting to run foreign executable, Dennis Williamson, 2021/10/04
- Re: Misleading error when attempting to run foreign executable, Chet Ramey, 2021/10/08
- Re: Misleading error when attempting to run foreign executable, Alex fxmbsw7 Ratchev, 2021/10/09
- Re: Misleading error when attempting to run foreign executable, Ángel, 2021/10/10
- Re: Misleading error when attempting to run foreign executable, Dmitry Goncharov, 2021/10/10
- Re: Misleading error when attempting to run foreign executable,
Eli Schwartz <=
- Re: Misleading error when attempting to run foreign executable, Dmitry Goncharov, 2021/10/10
- Re: Misleading error when attempting to run foreign executable, Robert Elz, 2021/10/11
- Re: Misleading error when attempting to run foreign executable, Chet Ramey, 2021/10/11
- Re: Misleading error when attempting to run foreign executable, Robert Elz, 2021/10/11
- Re: Misleading error when attempting to run foreign executable, Alex fxmbsw7 Ratchev, 2021/10/11
- Re: Misleading error when attempting to run foreign executable, Ángel, 2021/10/12
- Re: Misleading error when attempting to run foreign executable, Eli Schwartz, 2021/10/11