Bug 60870 - bash incorrectly reports missing program
bash incorrectly reports missing program
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
7.2
All Linux
medium Severity medium
: ---
: ---
Assigned To: wdovlrrw
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-03-07 21:07 EST by Ulrich Drepper
Modified: 2015-04-20 06:00 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-03-11 09:34:02 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
patch to implement check for PT_INTERP (5.57 KB, patch)
2002-03-07 21:08 EST, Ulrich Drepper
no flags Details | Diff
New patch which will also work on platforms with alignment requirements (6.17 KB, patch)
2002-03-08 04:01 EST, Ulrich Drepper
no flags Details | Diff

  None (edit)
Description Ulrich Drepper 2002-03-07 21:07:48 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9+) Gecko/20020306

Description of problem:
If a dynamically linked ELF binary is executed and the referenced ELF
interpreter (aka dynamic linker) is missing the report says that the executable
itself is missing.  This is of course bogus.  With some more work bash can
report the real reason.  I will append a patch for this.  It was also sent to
the bash maintainer for inclusion in the next release but it is important enough
to go in even without the upstream maintainer agreeing to it.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.echo 'int main () { return 0; }' > u.c
2.gcc -o u u.c -Wl,-dynamic-linker,/foo/bar/baz
3../u
	

Actual Results:  bash: ./u: No such file or directory


Expected Results:  bash: ./u: /foo/bar/baz: bad ELF interpreter: No such file or
directory

Additional info:
Comment 1 Ulrich Drepper 2002-03-07 21:08:28 EST
Created attachment 47840 [details]
patch to implement check for PT_INTERP
Comment 2 Ulrich Drepper 2002-03-08 04:01:44 EST
Created attachment 47881 [details]
New patch which will also work on platforms with alignment requirements
Comment 3 Bernhard Rosenkraenzer 2002-03-11 09:33:57 EST
Agreed, added to 2.05a-9. 
Comment 4 Kamil Dudka 2015-04-20 06:00:41 EDT
Comment on attachment 47881 [details]
New patch which will also work on platforms with alignment requirements

> +               do
> +                 {
> +                   if (actlen == maxlen)
> +                     {
> +                       char *newinterp = realloc (interp, maxlen += 200);
> +                       if (newinterp == NULL)
> +                         {
> +                           actlen = 0;
> +                           break;
> +                         }
> +                       interp = newinterp;
> +
> +#ifdef HAVE_PREAD
> +                       actlen = pread (fd, interp, maxlen, offset);
> +#else
> +                       if (lseek (fd, offset, SEEK_SET) != -1)
> +                         actlen = read (fd, interp, maxlen);
> +                       else
> +                         actlen = -1;
> +#endif
> +                     }
> +                 }
> +               while (actlen > 0 && memchr (interp, '\0', actlen) == NULL);

If (p)read reads less than maxlen bytes (and there is no NUL in the data), the code ends up in an infinite loop.

Note there is a different version of the patch, which should be free of this bug (originally intended for zsh):

http://www.zsh.org/mla/workers/2015/msg00833.html

Note You need to log in before you can comment on or make changes to this bug.