Bug 60870 - bash incorrectly reports missing program
Summary: bash incorrectly reports missing program
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: bash
Version: 7.2
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: wdovlrrw
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-03-08 02:07 UTC by Ulrich Drepper
Modified: 2018-10-30 15:51 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2002-03-11 14:34:02 UTC
Embargoed:


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


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1644353 0 unspecified CLOSED incorrect errormessage when 32bit exe is found in 64bit env. 2021-02-22 00:41:40 UTC

Internal Links: 1644353

Description Ulrich Drepper 2002-03-08 02:07:48 UTC
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-08 02:08:28 UTC
Created attachment 47840 [details]
patch to implement check for PT_INTERP

Comment 2 Ulrich Drepper 2002-03-08 09:01:44 UTC
Created attachment 47881 [details]
New patch which will also work on platforms with alignment requirements

Comment 3 Bernhard Rosenkraenzer 2002-03-11 14:33:57 UTC
Agreed, added to 2.05a-9. 


Comment 4 Kamil Dudka 2015-04-20 10:00:41 UTC
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.