Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 60870

Summary: bash incorrectly reports missing program
Product: [Retired] Red Hat Linux Reporter: Ulrich Drepper <drepper>
Component: bashAssignee: wdovlrrw <brosenkr>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: kdudka
Target Milestone: ---Keywords: FutureFeature
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-03-11 14:34:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
patch to implement check for PT_INTERP
none
New patch which will also work on platforms with alignment requirements none

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