|
|
3fb13f |
diff -up bash-4.2/execute_cmd.c.coverity bash-4.2/execute_cmd.c
|
|
|
3fb13f |
--- bash-4.2/execute_cmd.c.coverity 2011-02-24 13:04:35.000000000 +0100
|
|
|
3fb13f |
+++ bash-4.2/execute_cmd.c 2011-02-24 13:49:13.000000000 +0100
|
|
|
3fb13f |
@@ -5036,7 +5036,7 @@ shell_execve (command, args, env)
|
|
|
3fb13f |
Elf32_Ehdr ehdr;
|
|
|
3fb13f |
Elf32_Phdr *phdr;
|
|
|
3fb13f |
Elf32_Shdr *shdr;
|
|
|
3fb13f |
- int nphdr, nshdr;
|
|
|
3fb13f |
+ Elf32_Half nphdr, nshdr;
|
|
|
3fb13f |
|
|
|
3fb13f |
/* We have to copy the data since the sample buffer
|
|
|
3fb13f |
might not be aligned correctly to be accessed as
|
|
|
3fb13f |
@@ -5044,12 +5044,12 @@ shell_execve (command, args, env)
|
|
|
3fb13f |
memcpy (&ehdr, sample, sizeof (Elf32_Ehdr));
|
|
|
3fb13f |
|
|
|
3fb13f |
nshdr = ehdr.e_shnum;
|
|
|
3fb13f |
- shdr = (Elf32_Shdr *) malloc (nshdr * ehdr.e_shentsize);
|
|
|
3fb13f |
+ shdr = (Elf32_Shdr *) malloc ((size_t)nshdr * (size_t)ehdr.e_shentsize);
|
|
|
3fb13f |
|
|
|
3fb13f |
if (shdr != NULL)
|
|
|
3fb13f |
{
|
|
|
3fb13f |
#ifdef HAVE_PREAD
|
|
|
3fb13f |
- sample_len = pread (fd, shdr, nshdr * ehdr.e_shentsize,
|
|
|
3fb13f |
+ sample_len = pread (fd, shdr, (size_t)nshdr * (size_t)ehdr.e_shentsize,
|
|
|
3fb13f |
ehdr.e_shoff);
|
|
|
3fb13f |
#else
|
|
|
3fb13f |
if (lseek (fd, ehdr.e_shoff, SEEK_SET) != -1)
|
|
|
3fb13f |
@@ -5091,11 +5091,11 @@ shell_execve (command, args, env)
|
|
|
3fb13f |
}
|
|
|
3fb13f |
|
|
|
3fb13f |
nphdr = ehdr.e_phnum;
|
|
|
3fb13f |
- phdr = (Elf32_Phdr *) malloc (nphdr * ehdr.e_phentsize);
|
|
|
3fb13f |
+ phdr = (Elf32_Phdr *) malloc ((size_t)nphdr * (size_t)ehdr.e_phentsize);
|
|
|
3fb13f |
if (phdr != NULL)
|
|
|
3fb13f |
{
|
|
|
3fb13f |
#ifdef HAVE_PREAD
|
|
|
3fb13f |
- sample_len = pread (fd, phdr, nphdr * ehdr.e_phentsize,
|
|
|
3fb13f |
+ sample_len = pread (fd, phdr, (size_t)nphdr * (size_t)ehdr.e_phentsize,
|
|
|
3fb13f |
ehdr.e_phoff);
|
|
|
3fb13f |
#else
|
|
|
3fb13f |
if (lseek (fd, ehdr.e_phoff, SEEK_SET) != -1)
|
|
|
3fb13f |
@@ -5120,7 +5120,7 @@ shell_execve (command, args, env)
|
|
|
3fb13f |
Elf64_Ehdr ehdr;
|
|
|
3fb13f |
Elf64_Phdr *phdr;
|
|
|
3fb13f |
Elf64_Shdr *shdr;
|
|
|
3fb13f |
- int nphdr, nshdr;
|
|
|
3fb13f |
+ Elf32_Half nphdr, nshdr;
|
|
|
3fb13f |
|
|
|
3fb13f |
/* We have to copy the data since the sample buffer
|
|
|
3fb13f |
might not be aligned correctly to be accessed as
|
|
|
3fb13f |
@@ -5128,11 +5128,11 @@ shell_execve (command, args, env)
|
|
|
3fb13f |
memcpy (&ehdr, sample, sizeof (Elf64_Ehdr));
|
|
|
3fb13f |
|
|
|
3fb13f |
nshdr = ehdr.e_shnum;
|
|
|
3fb13f |
- shdr = (Elf64_Shdr *) malloc (nshdr * ehdr.e_shentsize);
|
|
|
3fb13f |
+ shdr = (Elf64_Shdr *) malloc ((size_t)nshdr * (size_t)ehdr.e_shentsize);
|
|
|
3fb13f |
if (shdr != NULL)
|
|
|
3fb13f |
{
|
|
|
3fb13f |
#ifdef HAVE_PREAD
|
|
|
3fb13f |
- sample_len = pread (fd, shdr, nshdr * ehdr.e_shentsize,
|
|
|
3fb13f |
+ sample_len = pread (fd, shdr, (size_t)nshdr * (size_t)ehdr.e_shentsize,
|
|
|
3fb13f |
ehdr.e_shoff);
|
|
|
3fb13f |
#else
|
|
|
3fb13f |
if (lseek (fd, ehdr.e_shoff, SEEK_SET) != -1)
|
|
|
3fb13f |
@@ -5174,11 +5174,11 @@ shell_execve (command, args, env)
|
|
|
3fb13f |
}
|
|
|
3fb13f |
|
|
|
3fb13f |
nphdr = ehdr.e_phnum;
|
|
|
3fb13f |
- phdr = (Elf64_Phdr *) malloc (nphdr * ehdr.e_phentsize);
|
|
|
3fb13f |
+ phdr = (Elf64_Phdr *) malloc ((size_t)nphdr * (size_t)ehdr.e_phentsize);
|
|
|
3fb13f |
if (phdr != NULL)
|
|
|
3fb13f |
{
|
|
|
3fb13f |
#ifdef HAVE_PREAD
|
|
|
3fb13f |
- sample_len = pread (fd, phdr, nphdr * ehdr.e_phentsize,
|
|
|
3fb13f |
+ sample_len = pread (fd, phdr, (size_t)nphdr * (size_t)ehdr.e_phentsize,
|
|
|
3fb13f |
ehdr.e_phoff);
|
|
|
3fb13f |
#else
|
|
|
3fb13f |
if (lseek (fd, ehdr.e_phoff, SEEK_SET) != -1)
|
|
|
3fb13f |
@@ -5200,8 +5200,8 @@ shell_execve (command, args, env)
|
|
|
3fb13f |
|
|
|
3fb13f |
if (offset != -1)
|
|
|
3fb13f |
{
|
|
|
3fb13f |
- size_t maxlen = 0;
|
|
|
3fb13f |
- size_t actlen = 0;
|
|
|
3fb13f |
+ ssize_t maxlen = 0;
|
|
|
3fb13f |
+ ssize_t actlen = 0;
|
|
|
3fb13f |
char *interp = NULL;
|
|
|
3fb13f |
|
|
|
3fb13f |
do
|
|
|
3fb13f |
@@ -5250,7 +5250,8 @@ shell_execve (command, args, env)
|
|
|
3fb13f |
}
|
|
|
3fb13f |
#endif
|
|
|
3fb13f |
#if defined (HAVE_HASH_BANG_EXEC) || defined (HAVE_ELF_H)
|
|
|
3fb13f |
- close (fd);
|
|
|
3fb13f |
+ if (fd >= 0)
|
|
|
3fb13f |
+ close (fd);
|
|
|
3fb13f |
#endif
|
|
|
3fb13f |
errno = i;
|
|
|
3fb13f |
file_error (command);
|