From: Cary Coutant Date: Wed, 10 Sep 2008 17:56:02 +0000 (+0000) Subject: 2008-09-05 Cary Coutant X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a9caad024e20635ecebb7be5330747fe23a7292b;p=binutils-gdb.git 2008-09-05 Cary Coutant * fileread.cc (File_read::make_view): Add check for attempt to map beyond end of file. --- diff --git a/gold/ChangeLog b/gold/ChangeLog index cac87e66e9a..1df7d746391 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,8 @@ +2008-09-05 Cary Coutant + + * fileread.cc (File_read::make_view): Add check for attempt to map + beyond end of file. + 2008-09-05 Cary Coutant * symtab.cc (Symbol_table::add_from_dynobj): Fix typos in diff --git a/gold/fileread.cc b/gold/fileread.cc index 8c2f8f34cf3..f56e33e39f1 100644 --- a/gold/fileread.cc +++ b/gold/fileread.cc @@ -355,6 +355,14 @@ File_read::make_view(off_t start, section_size_type size, { gold_assert(size > 0); + // Check that start and end of the view are within the file. + if (start > this->size_ || size > this->size_ - start) + gold_fatal(_("%s: attempt to map %lld bytes at offset %lld exceeds " + "size of file; the file may be corrupt"), + this->filename().c_str(), + static_cast(size), + static_cast(start)); + off_t poff = File_read::page_offset(start); section_size_type psize = File_read::pages(size + (start - poff));