]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - bash/patches/bash-4.2-coverity.patch
bash: Update to 4.3
[people/ms/ipfire-3.x.git] / bash / patches / bash-4.2-coverity.patch
1 diff -up bash-4.2/execute_cmd.c.coverity bash-4.2/execute_cmd.c
2 --- bash-4.2/execute_cmd.c.coverity 2011-02-24 13:04:35.000000000 +0100
3 +++ bash-4.2/execute_cmd.c 2011-02-24 13:49:13.000000000 +0100
4 @@ -5036,7 +5036,7 @@ shell_execve (command, args, env)
5 Elf32_Ehdr ehdr;
6 Elf32_Phdr *phdr;
7 Elf32_Shdr *shdr;
8 - int nphdr, nshdr;
9 + Elf32_Half nphdr, nshdr;
10
11 /* We have to copy the data since the sample buffer
12 might not be aligned correctly to be accessed as
13 @@ -5044,12 +5044,12 @@ shell_execve (command, args, env)
14 memcpy (&ehdr, sample, sizeof (Elf32_Ehdr));
15
16 nshdr = ehdr.e_shnum;
17 - shdr = (Elf32_Shdr *) malloc (nshdr * ehdr.e_shentsize);
18 + shdr = (Elf32_Shdr *) malloc ((size_t)nshdr * (size_t)ehdr.e_shentsize);
19
20 if (shdr != NULL)
21 {
22 #ifdef HAVE_PREAD
23 - sample_len = pread (fd, shdr, nshdr * ehdr.e_shentsize,
24 + sample_len = pread (fd, shdr, (size_t)nshdr * (size_t)ehdr.e_shentsize,
25 ehdr.e_shoff);
26 #else
27 if (lseek (fd, ehdr.e_shoff, SEEK_SET) != -1)
28 @@ -5091,11 +5091,11 @@ shell_execve (command, args, env)
29 }
30
31 nphdr = ehdr.e_phnum;
32 - phdr = (Elf32_Phdr *) malloc (nphdr * ehdr.e_phentsize);
33 + phdr = (Elf32_Phdr *) malloc ((size_t)nphdr * (size_t)ehdr.e_phentsize);
34 if (phdr != NULL)
35 {
36 #ifdef HAVE_PREAD
37 - sample_len = pread (fd, phdr, nphdr * ehdr.e_phentsize,
38 + sample_len = pread (fd, phdr, (size_t)nphdr * (size_t)ehdr.e_phentsize,
39 ehdr.e_phoff);
40 #else
41 if (lseek (fd, ehdr.e_phoff, SEEK_SET) != -1)
42 @@ -5120,7 +5120,7 @@ shell_execve (command, args, env)
43 Elf64_Ehdr ehdr;
44 Elf64_Phdr *phdr;
45 Elf64_Shdr *shdr;
46 - int nphdr, nshdr;
47 + Elf32_Half nphdr, nshdr;
48
49 /* We have to copy the data since the sample buffer
50 might not be aligned correctly to be accessed as
51 @@ -5128,11 +5128,11 @@ shell_execve (command, args, env)
52 memcpy (&ehdr, sample, sizeof (Elf64_Ehdr));
53
54 nshdr = ehdr.e_shnum;
55 - shdr = (Elf64_Shdr *) malloc (nshdr * ehdr.e_shentsize);
56 + shdr = (Elf64_Shdr *) malloc ((size_t)nshdr * (size_t)ehdr.e_shentsize);
57 if (shdr != NULL)
58 {
59 #ifdef HAVE_PREAD
60 - sample_len = pread (fd, shdr, nshdr * ehdr.e_shentsize,
61 + sample_len = pread (fd, shdr, (size_t)nshdr * (size_t)ehdr.e_shentsize,
62 ehdr.e_shoff);
63 #else
64 if (lseek (fd, ehdr.e_shoff, SEEK_SET) != -1)
65 @@ -5174,11 +5174,11 @@ shell_execve (command, args, env)
66 }
67
68 nphdr = ehdr.e_phnum;
69 - phdr = (Elf64_Phdr *) malloc (nphdr * ehdr.e_phentsize);
70 + phdr = (Elf64_Phdr *) malloc ((size_t)nphdr * (size_t)ehdr.e_phentsize);
71 if (phdr != NULL)
72 {
73 #ifdef HAVE_PREAD
74 - sample_len = pread (fd, phdr, nphdr * ehdr.e_phentsize,
75 + sample_len = pread (fd, phdr, (size_t)nphdr * (size_t)ehdr.e_phentsize,
76 ehdr.e_phoff);
77 #else
78 if (lseek (fd, ehdr.e_phoff, SEEK_SET) != -1)
79 @@ -5200,8 +5200,8 @@ shell_execve (command, args, env)
80
81 if (offset != -1)
82 {
83 - size_t maxlen = 0;
84 - size_t actlen = 0;
85 + ssize_t maxlen = 0;
86 + ssize_t actlen = 0;
87 char *interp = NULL;
88
89 do
90 @@ -5250,7 +5250,8 @@ shell_execve (command, args, env)
91 }
92 #endif
93 #if defined (HAVE_HASH_BANG_EXEC) || defined (HAVE_ELF_H)
94 - close (fd);
95 + if (fd >= 0)
96 + close (fd);
97 #endif
98 errno = i;
99 file_error (command);