diff options
Diffstat (limited to 'meta/recipes-devtools/binutils/binutils/binutils_CVE-2014-8502_1.patch')
-rw-r--r-- | meta/recipes-devtools/binutils/binutils/binutils_CVE-2014-8502_1.patch | 523 |
1 files changed, 0 insertions, 523 deletions
diff --git a/meta/recipes-devtools/binutils/binutils/binutils_CVE-2014-8502_1.patch b/meta/recipes-devtools/binutils/binutils/binutils_CVE-2014-8502_1.patch deleted file mode 100644 index 9e0c9c8b3c..0000000000 --- a/meta/recipes-devtools/binutils/binutils/binutils_CVE-2014-8502_1.patch +++ /dev/null | |||
@@ -1,523 +0,0 @@ | |||
1 | Upstream-Status: Backport | ||
2 | |||
3 | CVE-2014-8502 supporting patch. | ||
4 | |||
5 | [YOCTO #7084] | ||
6 | |||
7 | Signed-off-by: Armin Kuster <akuster808@gmail.com> | ||
8 | |||
9 | From bf67003b4567600ed3022a439207ac8f26454f91 Mon Sep 17 00:00:00 2001 | ||
10 | From: Nick Clifton <nickc@redhat.com> | ||
11 | Date: Mon, 27 Oct 2014 18:05:37 +0000 | ||
12 | Subject: [PATCH] This fixes more seg-faults in tools like "strings" and | ||
13 | "objdump" when presented with corrupt binaries. | ||
14 | |||
15 | PR binutils/17512 | ||
16 | * elf.c (bfd_section_from_shdr): Detect and warn about ELF | ||
17 | binaries with a group of sections linked by the string table | ||
18 | indicies. | ||
19 | * peXXigen.c (pe_print_edata): Detect out of range rvas and | ||
20 | entry counts for the Export Address table, Name Pointer table | ||
21 | and Ordinal table. | ||
22 | --- | ||
23 | bfd/ChangeLog | 5 ++ | ||
24 | bfd/elf.c | 194 ++++++++++++++++++++++++++++++++++++++------------------- | ||
25 | bfd/peXXigen.c | 18 +++++- | ||
26 | 3 files changed, 150 insertions(+), 67 deletions(-) | ||
27 | |||
28 | Index: binutils-2.24/bfd/elf.c | ||
29 | =================================================================== | ||
30 | --- binutils-2.24.orig/bfd/elf.c | ||
31 | +++ binutils-2.24/bfd/elf.c | ||
32 | @@ -1574,38 +1574,67 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
33 | Elf_Internal_Ehdr *ehdr; | ||
34 | const struct elf_backend_data *bed; | ||
35 | const char *name; | ||
36 | + bfd_boolean ret = TRUE; | ||
37 | + static bfd_boolean * sections_being_created = NULL; | ||
38 | + static unsigned int nesting = 0; | ||
39 | |||
40 | if (shindex >= elf_numsections (abfd)) | ||
41 | return FALSE; | ||
42 | |||
43 | + if (++ nesting > 3) | ||
44 | + { | ||
45 | + /* PR17512: A corrupt ELF binary might contain a recursive group of | ||
46 | + sections, each the string indicies pointing to the next in the | ||
47 | + loop. Detect this here, by refusing to load a section that we are | ||
48 | + already in the process of loading. We only trigger this test if | ||
49 | + we have nested at least three sections deep as normal ELF binaries | ||
50 | + can expect to recurse at least once. */ | ||
51 | + | ||
52 | + if (sections_being_created == NULL) | ||
53 | + { | ||
54 | + /* FIXME: It would be more efficient to attach this array to the bfd somehow. */ | ||
55 | + sections_being_created = (bfd_boolean *) | ||
56 | + bfd_zalloc (abfd, elf_numsections (abfd) * sizeof (bfd_boolean)); | ||
57 | + } | ||
58 | + if (sections_being_created [shindex]) | ||
59 | + { | ||
60 | + (*_bfd_error_handler) | ||
61 | + (_("%B: warning: loop in section dependencies detected"), abfd); | ||
62 | + return FALSE; | ||
63 | + } | ||
64 | + sections_being_created [shindex] = TRUE; | ||
65 | + } | ||
66 | + | ||
67 | hdr = elf_elfsections (abfd)[shindex]; | ||
68 | ehdr = elf_elfheader (abfd); | ||
69 | name = bfd_elf_string_from_elf_section (abfd, ehdr->e_shstrndx, | ||
70 | hdr->sh_name); | ||
71 | if (name == NULL) | ||
72 | - return FALSE; | ||
73 | + goto fail; | ||
74 | |||
75 | bed = get_elf_backend_data (abfd); | ||
76 | switch (hdr->sh_type) | ||
77 | { | ||
78 | case SHT_NULL: | ||
79 | /* Inactive section. Throw it away. */ | ||
80 | - return TRUE; | ||
81 | + goto success; | ||
82 | |||
83 | - case SHT_PROGBITS: /* Normal section with contents. */ | ||
84 | - case SHT_NOBITS: /* .bss section. */ | ||
85 | - case SHT_HASH: /* .hash section. */ | ||
86 | - case SHT_NOTE: /* .note section. */ | ||
87 | + case SHT_PROGBITS: /* Normal section with contents. */ | ||
88 | + case SHT_NOBITS: /* .bss section. */ | ||
89 | + case SHT_HASH: /* .hash section. */ | ||
90 | + case SHT_NOTE: /* .note section. */ | ||
91 | case SHT_INIT_ARRAY: /* .init_array section. */ | ||
92 | case SHT_FINI_ARRAY: /* .fini_array section. */ | ||
93 | case SHT_PREINIT_ARRAY: /* .preinit_array section. */ | ||
94 | case SHT_GNU_LIBLIST: /* .gnu.liblist section. */ | ||
95 | case SHT_GNU_HASH: /* .gnu.hash section. */ | ||
96 | - return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); | ||
97 | + ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); | ||
98 | + goto success; | ||
99 | |||
100 | case SHT_DYNAMIC: /* Dynamic linking information. */ | ||
101 | if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) | ||
102 | - return FALSE; | ||
103 | + goto fail; | ||
104 | + | ||
105 | if (hdr->sh_link > elf_numsections (abfd)) | ||
106 | { | ||
107 | /* PR 10478: Accept Solaris binaries with a sh_link | ||
108 | @@ -1619,11 +1648,11 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
109 | break; | ||
110 | /* Otherwise fall through. */ | ||
111 | default: | ||
112 | - return FALSE; | ||
113 | + goto fail; | ||
114 | } | ||
115 | } | ||
116 | else if (elf_elfsections (abfd)[hdr->sh_link] == NULL) | ||
117 | - return FALSE; | ||
118 | + goto fail; | ||
119 | else if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB) | ||
120 | { | ||
121 | Elf_Internal_Shdr *dynsymhdr; | ||
122 | @@ -1652,24 +1681,26 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | - break; | ||
127 | + goto success; | ||
128 | |||
129 | - case SHT_SYMTAB: /* A symbol table */ | ||
130 | + case SHT_SYMTAB: /* A symbol table. */ | ||
131 | if (elf_onesymtab (abfd) == shindex) | ||
132 | - return TRUE; | ||
133 | + goto success; | ||
134 | |||
135 | if (hdr->sh_entsize != bed->s->sizeof_sym) | ||
136 | - return FALSE; | ||
137 | + goto fail; | ||
138 | + | ||
139 | if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size) | ||
140 | { | ||
141 | if (hdr->sh_size != 0) | ||
142 | - return FALSE; | ||
143 | + goto fail; | ||
144 | /* Some assemblers erroneously set sh_info to one with a | ||
145 | zero sh_size. ld sees this as a global symbol count | ||
146 | of (unsigned) -1. Fix it here. */ | ||
147 | hdr->sh_info = 0; | ||
148 | - return TRUE; | ||
149 | + goto success; | ||
150 | } | ||
151 | + | ||
152 | BFD_ASSERT (elf_onesymtab (abfd) == 0); | ||
153 | elf_onesymtab (abfd) = shindex; | ||
154 | elf_tdata (abfd)->symtab_hdr = *hdr; | ||
155 | @@ -1686,7 +1717,7 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
156 | && (abfd->flags & DYNAMIC) != 0 | ||
157 | && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name, | ||
158 | shindex)) | ||
159 | - return FALSE; | ||
160 | + goto fail; | ||
161 | |||
162 | /* Go looking for SHT_SYMTAB_SHNDX too, since if there is one we | ||
163 | can't read symbols without that section loaded as well. It | ||
164 | @@ -1712,26 +1743,29 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
165 | break; | ||
166 | } | ||
167 | if (i != shindex) | ||
168 | - return bfd_section_from_shdr (abfd, i); | ||
169 | + ret = bfd_section_from_shdr (abfd, i); | ||
170 | } | ||
171 | - return TRUE; | ||
172 | + goto success; | ||
173 | |||
174 | - case SHT_DYNSYM: /* A dynamic symbol table */ | ||
175 | + case SHT_DYNSYM: /* A dynamic symbol table. */ | ||
176 | if (elf_dynsymtab (abfd) == shindex) | ||
177 | - return TRUE; | ||
178 | + goto success; | ||
179 | |||
180 | if (hdr->sh_entsize != bed->s->sizeof_sym) | ||
181 | - return FALSE; | ||
182 | + goto fail; | ||
183 | + | ||
184 | if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size) | ||
185 | { | ||
186 | if (hdr->sh_size != 0) | ||
187 | - return FALSE; | ||
188 | + goto fail; | ||
189 | + | ||
190 | /* Some linkers erroneously set sh_info to one with a | ||
191 | zero sh_size. ld sees this as a global symbol count | ||
192 | of (unsigned) -1. Fix it here. */ | ||
193 | hdr->sh_info = 0; | ||
194 | - return TRUE; | ||
195 | + goto success; | ||
196 | } | ||
197 | + | ||
198 | BFD_ASSERT (elf_dynsymtab (abfd) == 0); | ||
199 | elf_dynsymtab (abfd) = shindex; | ||
200 | elf_tdata (abfd)->dynsymtab_hdr = *hdr; | ||
201 | @@ -1740,34 +1774,38 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
202 | |||
203 | /* Besides being a symbol table, we also treat this as a regular | ||
204 | section, so that objcopy can handle it. */ | ||
205 | - return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); | ||
206 | + ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); | ||
207 | + goto success; | ||
208 | |||
209 | - case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections */ | ||
210 | + case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections. */ | ||
211 | if (elf_symtab_shndx (abfd) == shindex) | ||
212 | - return TRUE; | ||
213 | + goto success; | ||
214 | |||
215 | BFD_ASSERT (elf_symtab_shndx (abfd) == 0); | ||
216 | elf_symtab_shndx (abfd) = shindex; | ||
217 | elf_tdata (abfd)->symtab_shndx_hdr = *hdr; | ||
218 | elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->symtab_shndx_hdr; | ||
219 | - return TRUE; | ||
220 | + goto success; | ||
221 | |||
222 | - case SHT_STRTAB: /* A string table */ | ||
223 | + case SHT_STRTAB: /* A string table. */ | ||
224 | if (hdr->bfd_section != NULL) | ||
225 | - return TRUE; | ||
226 | + goto success; | ||
227 | + | ||
228 | if (ehdr->e_shstrndx == shindex) | ||
229 | { | ||
230 | elf_tdata (abfd)->shstrtab_hdr = *hdr; | ||
231 | elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr; | ||
232 | - return TRUE; | ||
233 | + goto success; | ||
234 | } | ||
235 | + | ||
236 | if (elf_elfsections (abfd)[elf_onesymtab (abfd)]->sh_link == shindex) | ||
237 | { | ||
238 | symtab_strtab: | ||
239 | elf_tdata (abfd)->strtab_hdr = *hdr; | ||
240 | elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->strtab_hdr; | ||
241 | - return TRUE; | ||
242 | + goto success; | ||
243 | } | ||
244 | + | ||
245 | if (elf_elfsections (abfd)[elf_dynsymtab (abfd)]->sh_link == shindex) | ||
246 | { | ||
247 | dynsymtab_strtab: | ||
248 | @@ -1776,8 +1814,9 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
249 | elf_elfsections (abfd)[shindex] = hdr; | ||
250 | /* We also treat this as a regular section, so that objcopy | ||
251 | can handle it. */ | ||
252 | - return _bfd_elf_make_section_from_shdr (abfd, hdr, name, | ||
253 | - shindex); | ||
254 | + ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, | ||
255 | + shindex); | ||
256 | + goto success; | ||
257 | } | ||
258 | |||
259 | /* If the string table isn't one of the above, then treat it as a | ||
260 | @@ -1795,9 +1834,9 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
261 | { | ||
262 | /* Prevent endless recursion on broken objects. */ | ||
263 | if (i == shindex) | ||
264 | - return FALSE; | ||
265 | + goto fail; | ||
266 | if (! bfd_section_from_shdr (abfd, i)) | ||
267 | - return FALSE; | ||
268 | + goto fail; | ||
269 | if (elf_onesymtab (abfd) == i) | ||
270 | goto symtab_strtab; | ||
271 | if (elf_dynsymtab (abfd) == i) | ||
272 | @@ -1805,7 +1844,8 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
273 | } | ||
274 | } | ||
275 | } | ||
276 | - return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); | ||
277 | + ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); | ||
278 | + goto success; | ||
279 | |||
280 | case SHT_REL: | ||
281 | case SHT_RELA: | ||
282 | @@ -1820,7 +1860,7 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
283 | if (hdr->sh_entsize | ||
284 | != (bfd_size_type) (hdr->sh_type == SHT_REL | ||
285 | ? bed->s->sizeof_rel : bed->s->sizeof_rela)) | ||
286 | - return FALSE; | ||
287 | + goto fail; | ||
288 | |||
289 | /* Check for a bogus link to avoid crashing. */ | ||
290 | if (hdr->sh_link >= num_sec) | ||
291 | @@ -1828,8 +1868,9 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
292 | ((*_bfd_error_handler) | ||
293 | (_("%B: invalid link %lu for reloc section %s (index %u)"), | ||
294 | abfd, hdr->sh_link, name, shindex)); | ||
295 | - return _bfd_elf_make_section_from_shdr (abfd, hdr, name, | ||
296 | - shindex); | ||
297 | + ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, | ||
298 | + shindex); | ||
299 | + goto success; | ||
300 | } | ||
301 | |||
302 | /* For some incomprehensible reason Oracle distributes | ||
303 | @@ -1870,7 +1911,7 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
304 | if ((elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB | ||
305 | || elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_DYNSYM) | ||
306 | && ! bfd_section_from_shdr (abfd, hdr->sh_link)) | ||
307 | - return FALSE; | ||
308 | + goto fail; | ||
309 | |||
310 | /* If this reloc section does not use the main symbol table we | ||
311 | don't treat it as a reloc section. BFD can't adequately | ||
312 | @@ -1885,14 +1926,18 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
313 | || hdr->sh_info >= num_sec | ||
314 | || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL | ||
315 | || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELA) | ||
316 | - return _bfd_elf_make_section_from_shdr (abfd, hdr, name, | ||
317 | - shindex); | ||
318 | + { | ||
319 | + ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, | ||
320 | + shindex); | ||
321 | + goto success; | ||
322 | + } | ||
323 | |||
324 | if (! bfd_section_from_shdr (abfd, hdr->sh_info)) | ||
325 | - return FALSE; | ||
326 | + goto fail; | ||
327 | + | ||
328 | target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info); | ||
329 | if (target_sect == NULL) | ||
330 | - return FALSE; | ||
331 | + goto fail; | ||
332 | |||
333 | esdt = elf_section_data (target_sect); | ||
334 | if (hdr->sh_type == SHT_RELA) | ||
335 | @@ -1904,7 +1949,7 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
336 | amt = sizeof (*hdr2); | ||
337 | hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt); | ||
338 | if (hdr2 == NULL) | ||
339 | - return FALSE; | ||
340 | + goto fail; | ||
341 | *hdr2 = *hdr; | ||
342 | *p_hdr = hdr2; | ||
343 | elf_elfsections (abfd)[shindex] = hdr2; | ||
344 | @@ -1920,34 +1965,40 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
345 | target_sect->use_rela_p = 1; | ||
346 | } | ||
347 | abfd->flags |= HAS_RELOC; | ||
348 | - return TRUE; | ||
349 | + goto success; | ||
350 | } | ||
351 | |||
352 | case SHT_GNU_verdef: | ||
353 | elf_dynverdef (abfd) = shindex; | ||
354 | elf_tdata (abfd)->dynverdef_hdr = *hdr; | ||
355 | - return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); | ||
356 | + ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); | ||
357 | + goto success; | ||
358 | |||
359 | case SHT_GNU_versym: | ||
360 | if (hdr->sh_entsize != sizeof (Elf_External_Versym)) | ||
361 | - return FALSE; | ||
362 | + goto fail; | ||
363 | + | ||
364 | elf_dynversym (abfd) = shindex; | ||
365 | elf_tdata (abfd)->dynversym_hdr = *hdr; | ||
366 | - return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); | ||
367 | + ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); | ||
368 | + goto success; | ||
369 | |||
370 | case SHT_GNU_verneed: | ||
371 | elf_dynverref (abfd) = shindex; | ||
372 | elf_tdata (abfd)->dynverref_hdr = *hdr; | ||
373 | - return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); | ||
374 | + ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); | ||
375 | + goto success; | ||
376 | |||
377 | case SHT_SHLIB: | ||
378 | - return TRUE; | ||
379 | + goto success; | ||
380 | |||
381 | case SHT_GROUP: | ||
382 | if (! IS_VALID_GROUP_SECTION_HEADER (hdr, GRP_ENTRY_SIZE)) | ||
383 | - return FALSE; | ||
384 | + goto fail; | ||
385 | + | ||
386 | if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) | ||
387 | - return FALSE; | ||
388 | + goto fail; | ||
389 | + | ||
390 | if (hdr->contents != NULL) | ||
391 | { | ||
392 | Elf_Internal_Group *idx = (Elf_Internal_Group *) hdr->contents; | ||
393 | @@ -1973,7 +2024,7 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
394 | } | ||
395 | } | ||
396 | } | ||
397 | - break; | ||
398 | + goto success; | ||
399 | |||
400 | default: | ||
401 | /* Possibly an attributes section. */ | ||
402 | @@ -1981,14 +2032,14 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
403 | || hdr->sh_type == bed->obj_attrs_section_type) | ||
404 | { | ||
405 | if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) | ||
406 | - return FALSE; | ||
407 | + goto fail; | ||
408 | _bfd_elf_parse_attributes (abfd, hdr); | ||
409 | - return TRUE; | ||
410 | + goto success; | ||
411 | } | ||
412 | |||
413 | /* Check for any processor-specific section types. */ | ||
414 | if (bed->elf_backend_section_from_shdr (abfd, hdr, name, shindex)) | ||
415 | - return TRUE; | ||
416 | + goto success; | ||
417 | |||
418 | if (hdr->sh_type >= SHT_LOUSER && hdr->sh_type <= SHT_HIUSER) | ||
419 | { | ||
420 | @@ -2000,9 +2051,12 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
421 | "specific section `%s' [0x%8x]"), | ||
422 | abfd, name, hdr->sh_type); | ||
423 | else | ||
424 | - /* Allow sections reserved for applications. */ | ||
425 | - return _bfd_elf_make_section_from_shdr (abfd, hdr, name, | ||
426 | - shindex); | ||
427 | + { | ||
428 | + /* Allow sections reserved for applications. */ | ||
429 | + ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, | ||
430 | + shindex); | ||
431 | + goto success; | ||
432 | + } | ||
433 | } | ||
434 | else if (hdr->sh_type >= SHT_LOPROC | ||
435 | && hdr->sh_type <= SHT_HIPROC) | ||
436 | @@ -2023,8 +2077,11 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
437 | "`%s' [0x%8x]"), | ||
438 | abfd, name, hdr->sh_type); | ||
439 | else | ||
440 | - /* Otherwise it should be processed. */ | ||
441 | - return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); | ||
442 | + { | ||
443 | + /* Otherwise it should be processed. */ | ||
444 | + ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); | ||
445 | + goto success; | ||
446 | + } | ||
447 | } | ||
448 | else | ||
449 | /* FIXME: We should handle this section. */ | ||
450 | @@ -2032,10 +2089,17 @@ bfd_section_from_shdr (bfd *abfd, unsign | ||
451 | (_("%B: don't know how to handle section `%s' [0x%8x]"), | ||
452 | abfd, name, hdr->sh_type); | ||
453 | |||
454 | - return FALSE; | ||
455 | + goto fail; | ||
456 | } | ||
457 | |||
458 | - return TRUE; | ||
459 | + fail: | ||
460 | + ret = FALSE; | ||
461 | + success: | ||
462 | + if (sections_being_created) | ||
463 | + sections_being_created [shindex] = FALSE; | ||
464 | + if (-- nesting == 0) | ||
465 | + sections_being_created = NULL; | ||
466 | + return ret; | ||
467 | } | ||
468 | |||
469 | /* Return the local symbol specified by ABFD, R_SYMNDX. */ | ||
470 | Index: binutils-2.24/bfd/peXXigen.c | ||
471 | =================================================================== | ||
472 | --- binutils-2.24.orig/bfd/peXXigen.c | ||
473 | +++ binutils-2.24/bfd/peXXigen.c | ||
474 | @@ -1528,7 +1528,12 @@ pe_print_edata (bfd * abfd, void * vfile | ||
475 | _("\nExport Address Table -- Ordinal Base %ld\n"), | ||
476 | edt.base); | ||
477 | |||
478 | - for (i = 0; i < edt.num_functions; ++i) | ||
479 | + /* PR 17512: Handle corrupt PE binaries. */ | ||
480 | + if (edt.eat_addr + (edt.num_functions * 4) - adj >= datasize) | ||
481 | + fprintf (file, _("\tInvalid Export Address Table rva (0x%lx) or entry count (0x%lx)\n"), | ||
482 | + (long) edt.eat_addr, | ||
483 | + (long) edt.num_functions); | ||
484 | + else for (i = 0; i < edt.num_functions; ++i) | ||
485 | { | ||
486 | bfd_vma eat_member = bfd_get_32 (abfd, | ||
487 | data + edt.eat_addr + (i * 4) - adj); | ||
488 | @@ -1564,7 +1569,16 @@ pe_print_edata (bfd * abfd, void * vfile | ||
489 | fprintf (file, | ||
490 | _("\n[Ordinal/Name Pointer] Table\n")); | ||
491 | |||
492 | - for (i = 0; i < edt.num_names; ++i) | ||
493 | + /* PR 17512: Handle corrupt PE binaries. */ | ||
494 | + if (edt.npt_addr + (edt.num_names * 4) - adj >= datasize) | ||
495 | + fprintf (file, _("\tInvalid Name Pointer Table rva (0x%lx) or entry count (0x%lx)\n"), | ||
496 | + (long) edt.npt_addr, | ||
497 | + (long) edt.num_names); | ||
498 | + else if (edt.ot_addr + (edt.num_names * 2) - adj >= datasize) | ||
499 | + fprintf (file, _("\tInvalid Ordinal Table rva (0x%lx) or entry count (0x%lx)\n"), | ||
500 | + (long) edt.ot_addr, | ||
501 | + (long) edt.num_names); | ||
502 | + else for (i = 0; i < edt.num_names; ++i) | ||
503 | { | ||
504 | bfd_vma name_ptr = bfd_get_32 (abfd, | ||
505 | data + | ||
506 | Index: binutils-2.24/bfd/ChangeLog | ||
507 | =================================================================== | ||
508 | --- binutils-2.24.orig/bfd/ChangeLog | ||
509 | +++ binutils-2.24/bfd/ChangeLog | ||
510 | @@ -1,8 +1,13 @@ | ||
511 | 2014-10-27 Nick Clifton <nickc@redhat.com> | ||
512 | |||
513 | PR binutils/17512 | ||
514 | + * elf.c (bfd_section_from_shdr): Detect and warn about ELF | ||
515 | + binaries with a group of sections linked by the string table | ||
516 | + indicies. | ||
517 | * peXXigen.c (_bfd_XXi_swap_aouthdr_in): Handle corrupt binaries | ||
518 | with an invalid value for NumberOfRvaAndSizes. | ||
519 | + (pe_print_edata): Detect out of range rvas and entry counts for | ||
520 | + the Export Address table, Name Pointer table and Ordinal table. | ||
521 | |||
522 | PR binutils/17510 | ||
523 | * elf.c (setup_group): Improve handling of corrupt group | ||