• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修订版c616591359a014fcfdb5acb48e70ecda0823fb46 (tree)
时间2016-08-30 21:51:43
作者Nick Clifton <nickc@redh...>
CommiterNick Clifton

Log Message

Partially revert previous delta - move limit testing code to first scan over symbol file.

PR gprof/20499
* corefile.c (num_of_syms_in): Return an unsigned int.
Fail if the count exceeds the maximum possible allocatable size.
(core_create_syms_from): Exit early if num_of_syms_in returns a
failure code.

更改概述

差异

--- a/gprof/ChangeLog
+++ b/gprof/ChangeLog
@@ -2,10 +2,9 @@
22
33 PR gprof/20499
44 * corefile.c (num_of_syms_in): Return an unsigned int.
5- (core_create_syms_from): Catch a possible integer overflow
6- computing the argument to xmalloc. Also allow for the possibility
7- that an integer overflow in num_of_syms_in means that less space
8- has been allocated than expected.
5+ Fail if the count exceeds the maximum possible allocatable size.
6+ (core_create_syms_from): Exit early if num_of_syms_in returns a
7+ failure code.
98
109 2016-08-23 Nick Clifton <nickc@redhat.com>
1110
--- a/gprof/corefile.c
+++ b/gprof/corefile.c
@@ -28,6 +28,7 @@
2828 #include "hist.h"
2929 #include "corefile.h"
3030 #include "safe-ctype.h"
31+#include <limits.h> /* For UINT_MAX. */
3132
3233 bfd *core_bfd;
3334 static int core_num_syms;
@@ -500,7 +501,11 @@ num_of_syms_in (FILE * f)
500501 {
501502 if (sscanf (buf, "%" STR_BUFSIZE "s %c %" STR_BUFSIZE "s", address, &type, name) == 3)
502503 if (type == 't' || type == 'T')
503- ++num;
504+ {
505+ /* PR 20499 - prevent integer overflow computing argument to xmalloc. */
506+ if (++num >= UINT_MAX / sizeof (Sym))
507+ return -1U;
508+ }
504509 }
505510
506511 return num;
@@ -531,11 +536,10 @@ core_create_syms_from (const char * sym_table_file)
531536 fprintf (stderr, _("%s: file `%s' has no symbols\n"), whoami, sym_table_file);
532537 done (1);
533538 }
534- /* PR 20499 - prevent integer overflow computing argument to xmalloc. */
535- else if ((symtab.len * (unsigned) sizeof (Sym)) < symtab.len)
539+ else if (symtab.len == -1U)
536540 {
537- fprintf (stderr, _("%s: file `%s' has too many symbols: %u\n"),
538- whoami, sym_table_file, symtab.len);
541+ fprintf (stderr, _("%s: file `%s' has too many symbols\n"),
542+ whoami, sym_table_file);
539543 done (1);
540544 }
541545
@@ -571,12 +575,6 @@ core_create_syms_from (const char * sym_table_file)
571575 max_vma = MAX (symtab.limit->addr, max_vma);
572576
573577 ++symtab.limit;
574- /* PR 20499 - it is theoretically possible that there are so many
575- symbols in the file that the scan in num_of_syms_in() wrapped
576- around. So be paranoid here and exit the loop if we have
577- reached the end of our allocated table. */
578- if ((unsigned int)(symtab.limit - symtab.base) == symtab.len)
579- break;
580578 }
581579 fclose (f);
582580