rpms/bash/devel bash-4.0-nobits.patch, NONE, 1.1 bash.spec, 1.187, 1.188

Roman Rakus rrakus at fedoraproject.org
Fri Sep 4 12:59:22 UTC 2009


Author: rrakus

Update of /cvs/extras/rpms/bash/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv5642

Modified Files:
	bash.spec 
Added Files:
	bash-4.0-nobits.patch 
Log Message:
check if interp section is NOBITS. define Recycles pids

bash-4.0-nobits.patch:
 execute_cmd.c |  111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 107 insertions(+), 4 deletions(-)

--- NEW FILE bash-4.0-nobits.patch ---
diff -up bash-4.0/execute_cmd.c.nobits bash-4.0/execute_cmd.c
--- bash-4.0/execute_cmd.c.nobits	2009-08-11 11:53:38.000000000 +0200
+++ bash-4.0/execute_cmd.c	2009-08-14 16:18:18.000000000 +0200
@@ -4747,6 +4747,7 @@ shell_execve (command, args, env)
 	      && memcmp (sample, ELFMAG, SELFMAG) == 0)
 	    {
 	      off_t offset = -1;
+              int dynamic_nobits = 0;
 
 	      /* It is an ELF file.  Now determine whether it is dynamically
 		 linked and if yes, get the offset of the interpreter
@@ -4756,13 +4757,61 @@ shell_execve (command, args, env)
 		{
 		  Elf32_Ehdr ehdr;
 		  Elf32_Phdr *phdr;
-		  int nphdr;
+                  Elf32_Shdr *shdr;
+		  int nphdr, nshdr;
 
 		  /* We have to copy the data since the sample buffer
 		     might not be aligned correctly to be accessed as
 		     an Elf32_Ehdr struct.  */
 		  memcpy (&ehdr, sample, sizeof (Elf32_Ehdr));
 
+		  nshdr = ehdr.e_shnum;
+		  shdr = (Elf32_Shdr *) malloc (nshdr * ehdr.e_shentsize);
+                  
+		  if (shdr != NULL)
+		    {
+#ifdef HAVE_PREAD
+		      sample_len = pread (fd, shdr, nshdr * ehdr.e_shentsize,
+					  ehdr.e_shoff);
+#else
+		      if (lseek (fd, ehdr.e_shoff, SEEK_SET) != -1)
+			sample_len = read (fd, shdr,
+					   nshdr * ehdr.e_shentsize);
+		      else
+			sample_len = -1;
+#endif
+		      if (sample_len == nshdr * ehdr.e_shentsize)
+                        {
+                          char *strings = (char *) malloc (shdr[ehdr.e_shstrndx].sh_size);
+                          if (strings != NULL)
+                            {
+#ifdef HAVE_PREAD
+		              sample_len = pread (fd, strings,
+                                             shdr[ehdr.e_shstrndx].sh_size,
+					     shdr[ehdr.e_shstrndx].sh_offset);
+#else
+		              if (lseek (fd, shdr[ehdr.e_shstrndx].sh_offset,
+                                         SEEK_SET) != -1)
+			        sample_len = read (fd, strings,
+			  		       shdr[ehdr.e_shstrndx].sh_size);
+		              else
+			        sample_len = -1;
+#endif
+                              if (sample_len == shdr[ehdr.e_shstrndx].sh_size)
+			        while (nshdr-- > 0)
+                                  if (strcmp (strings + shdr[nshdr].sh_name,
+                                              ".interp") == 0 &&
+                                      shdr[nshdr].sh_type == SHT_NOBITS)
+                                    {
+                                      dynamic_nobits++;
+                                      break;
+                                    }
+                              free (strings);
+                            }
+                        }
+		      free (shdr);
+		    }
+
 		  nphdr = ehdr.e_phnum;
 		  phdr = (Elf32_Phdr *) malloc (nphdr * ehdr.e_phentsize);
 		  if (phdr != NULL)
@@ -4792,13 +4841,60 @@ shell_execve (command, args, env)
 		{
 		  Elf64_Ehdr ehdr;
 		  Elf64_Phdr *phdr;
-		  int nphdr;
+                  Elf64_Shdr *shdr;
+		  int nphdr, nshdr;
 
 		  /* We have to copy the data since the sample buffer
 		     might not be aligned correctly to be accessed as
 		     an Elf64_Ehdr struct.  */
 		  memcpy (&ehdr, sample, sizeof (Elf64_Ehdr));
 
+		  nshdr = ehdr.e_shnum;
+		  shdr = (Elf64_Shdr *) malloc (nshdr * ehdr.e_shentsize);
+		  if (shdr != NULL)
+		    {
+#ifdef HAVE_PREAD
+		      sample_len = pread (fd, shdr, nshdr * ehdr.e_shentsize,
+					  ehdr.e_shoff);
+#else
+		      if (lseek (fd, ehdr.e_shoff, SEEK_SET) != -1)
+			sample_len = read (fd, shdr,
+					   nshdr * ehdr.e_shentsize);
+		      else
+			sample_len = -1;
+#endif
+		      if (sample_len == nshdr * ehdr.e_shentsize)
+                        {
+                          char *strings = (char *) malloc (shdr[ehdr.e_shstrndx].sh_size);
+                          if (strings != NULL)
+                            {
+#ifdef HAVE_PREAD
+		              sample_len = pread (fd, strings,
+                                             shdr[ehdr.e_shstrndx].sh_size,
+					     shdr[ehdr.e_shstrndx].sh_offset);
+#else
+		              if (lseek (fd, shdr[ehdr.e_shstrndx].sh_offset,
+                                         SEEK_SET) != -1)
+			        sample_len = read (fd, strings,
+			  		       shdr[ehdr.e_shstrndx].sh_size);
+		              else
+			        sample_len = -1;
+#endif
+                              if (sample_len == shdr[ehdr.e_shstrndx].sh_size)
+			        while (nshdr-- > 0)
+                                  if (strcmp (strings + shdr[nshdr].sh_name,
+                                              ".interp") == 0 &&
+                                      shdr[nshdr].sh_type == SHT_NOBITS)
+                                    {
+                                      dynamic_nobits++;
+                                      break;
+                                    }
+                              free (strings);
+                            }
+                        }
+		      free (shdr);
+		    }
+
 		  nphdr = ehdr.e_phnum;
 		  phdr = (Elf64_Phdr *) malloc (nphdr * ehdr.e_phentsize);
 		  if (phdr != NULL)
@@ -4858,8 +4954,15 @@ shell_execve (command, args, env)
 		    {
 		      close (fd);
 		      errno = i;
-		      sys_error ("%s: %s: bad ELF interpreter", command,
-				 interp);
+                      if (dynamic_nobits > 0)
+                        {
+                          sys_error ("%s: bad ELF interpreter", command);
+                        }
+                      else
+                        {
+		          sys_error ("%s: %s: bad ELF interpreter", command,
+				     interp);
+                        }
 		      free (interp);
 		      return (EX_NOEXEC);
 		    }


Index: bash.spec
===================================================================
RCS file: /cvs/extras/rpms/bash/devel/bash.spec,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -p -r1.187 -r1.188
--- bash.spec	26 Aug 2009 14:53:31 -0000	1.187
+++ bash.spec	4 Sep 2009 12:59:22 -0000	1.188
@@ -74,6 +74,9 @@ Patch118: bash-tty-tests.patch
 # 518644, alloc memory for key in associative array creation
 Patch122: bash-4.0-key_alloc.patch
 
+# 484809, check if interp section is NOBITS
+Patch123: bash-4.0-nobits.patch
+
 Requires(post): ncurses-libs
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -154,6 +157,7 @@ This package contains documentation file
 #%patch120 -p1 -b .no_debug_output
 #%patch121 -p1 -b .pipelines_handling
 %patch122 -p1 -b .key_alloc
+%patch123 -p1 -b .nobits
 
 echo %{version} > _distribution
 echo %{release} > _patchlevel
@@ -161,8 +165,11 @@ echo %{release} > _patchlevel
 %build
 autoconf
 %configure --with-bash-malloc=no --with-afs
-make "CPPFLAGS=-D_GNU_SOURCE `getconf LFS_CFLAGS`"
-#make "CPPFLAGS=-DUSE_POSIX_GLOB_LIBRARY -D_GNU_SOURCE `getconf LFS_CFLAGS`"
+
+# Recycles pids is neccessary. When bash's last fork's pid was X
+# and new fork's pid is also X, bash has to wait for this same pid.
+# Without Recycles pids bash will not wait.
+make "CPPFLAGS=-D_GNU_SOURCE -DRECYCLES_PIDS `getconf LFS_CFLAGS`"
 %check
 make check
 
@@ -317,6 +324,10 @@ fi
 #%doc doc/*.ps doc/*.0 doc/*.html doc/article.txt
 
 %changelog
+* Fri Sep 04 2009 Roman Rakus <rrakus at redhat.com> - 4.0.28-3
+- check if interp section is NOBITS
+- define Recycles pids
+
 * Wed Aug 26 2009 Roman Rakus <rrakus at redhat.com> - 4.0.28-2
 - alloc memory for key in creation associative array (#518644)
 




More information about the fedora-extras-commits mailing list