1 diff -up bash-4.0/execute_cmd.c.nobits bash-4.0/execute_cmd.c
2 --- bash-4.0/execute_cmd.c.nobits 2009-08-11 11:53:38.000000000 +0200
3 +++ bash-4.0/execute_cmd.c 2009-08-14 16:18:18.000000000 +0200
4 @@ -4747,6 +4747,7 @@ shell_execve (command, args, env)
5 && memcmp (sample, ELFMAG, SELFMAG) == 0)
8 + int dynamic_nobits = 0;
10 /* It is an ELF file. Now determine whether it is dynamically
11 linked and if yes, get the offset of the interpreter
12 @@ -4756,13 +4757,61 @@ shell_execve (command, args, env)
20 /* We have to copy the data since the sample buffer
21 might not be aligned correctly to be accessed as
22 an Elf32_Ehdr struct. */
23 memcpy (&ehdr, sample, sizeof (Elf32_Ehdr));
25 + nshdr = ehdr.e_shnum;
26 + shdr = (Elf32_Shdr *) malloc (nshdr * ehdr.e_shentsize);
31 + sample_len = pread (fd, shdr, nshdr * ehdr.e_shentsize,
34 + if (lseek (fd, ehdr.e_shoff, SEEK_SET) != -1)
35 + sample_len = read (fd, shdr,
36 + nshdr * ehdr.e_shentsize);
40 + if (sample_len == nshdr * ehdr.e_shentsize)
42 + char *strings = (char *) malloc (shdr[ehdr.e_shstrndx].sh_size);
43 + if (strings != NULL)
46 + sample_len = pread (fd, strings,
47 + shdr[ehdr.e_shstrndx].sh_size,
48 + shdr[ehdr.e_shstrndx].sh_offset);
50 + if (lseek (fd, shdr[ehdr.e_shstrndx].sh_offset,
52 + sample_len = read (fd, strings,
53 + shdr[ehdr.e_shstrndx].sh_size);
57 + if (sample_len == shdr[ehdr.e_shstrndx].sh_size)
59 + if (strcmp (strings + shdr[nshdr].sh_name,
61 + shdr[nshdr].sh_type == SHT_NOBITS)
73 phdr = (Elf32_Phdr *) malloc (nphdr * ehdr.e_phentsize);
75 @@ -4792,13 +4841,60 @@ shell_execve (command, args, env)
83 /* We have to copy the data since the sample buffer
84 might not be aligned correctly to be accessed as
85 an Elf64_Ehdr struct. */
86 memcpy (&ehdr, sample, sizeof (Elf64_Ehdr));
88 + nshdr = ehdr.e_shnum;
89 + shdr = (Elf64_Shdr *) malloc (nshdr * ehdr.e_shentsize);
93 + sample_len = pread (fd, shdr, nshdr * ehdr.e_shentsize,
96 + if (lseek (fd, ehdr.e_shoff, SEEK_SET) != -1)
97 + sample_len = read (fd, shdr,
98 + nshdr * ehdr.e_shentsize);
102 + if (sample_len == nshdr * ehdr.e_shentsize)
104 + char *strings = (char *) malloc (shdr[ehdr.e_shstrndx].sh_size);
105 + if (strings != NULL)
108 + sample_len = pread (fd, strings,
109 + shdr[ehdr.e_shstrndx].sh_size,
110 + shdr[ehdr.e_shstrndx].sh_offset);
112 + if (lseek (fd, shdr[ehdr.e_shstrndx].sh_offset,
114 + sample_len = read (fd, strings,
115 + shdr[ehdr.e_shstrndx].sh_size);
119 + if (sample_len == shdr[ehdr.e_shstrndx].sh_size)
120 + while (nshdr-- > 0)
121 + if (strcmp (strings + shdr[nshdr].sh_name,
123 + shdr[nshdr].sh_type == SHT_NOBITS)
134 nphdr = ehdr.e_phnum;
135 phdr = (Elf64_Phdr *) malloc (nphdr * ehdr.e_phentsize);
137 @@ -4858,8 +4954,15 @@ shell_execve (command, args, env)
141 - sys_error ("%s: %s: bad ELF interpreter", command,
143 + if (dynamic_nobits > 0)
145 + sys_error ("%s: bad ELF interpreter", command);
149 + sys_error ("%s: %s: bad ELF interpreter", command,