summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/binutils/binutils/0014-CVE-2019-1010204.patch
blob: dad4a62038fca87d4a6c362b37521706a5769a6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
From 2a4fc266dbf77ed7ab83da16468e9ba627b8bc2d Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@redhat.com>
Date: Mon, 27 Jun 2022 13:07:40 +0100
Subject: [PATCH] Have gold's File_read::do_read() function check the start
 parameter

	PR 23765
	* fileread.cc (File_read::do_read): Check start parameter before
	computing number of bytes to read.

Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2a4fc266dbf77ed7ab83da16468e9ba627b8bc2d]

Signed-off-by: Pgowda <pgowda.cve@gmail.com>
---
 gold/ChangeLog   | 6 ++++++
 gold/fileread.cc | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index 5103dab7b67..8557dc6db7f 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,9 @@
+2022-06-27  Nick Clifton  <nickc@redhat.com>
+
+	PR 23765
+	* fileread.cc (File_read::do_read): Check start parameter before
+	computing number of bytes to read.
+
 2022-02-17  Nick Clifton  <nickc@redhat.com>
 
 	* po/sr.po: Updated Serbian translation.
diff --git a/gold/fileread.cc b/gold/fileread.cc
index 2b653f78c2e..af2df215468 100644
--- a/gold/fileread.cc
+++ b/gold/fileread.cc
@@ -385,6 +385,12 @@ File_read::do_read(off_t start, section_
   ssize_t bytes;
   if (this->whole_file_view_ != NULL)
     {
+      // See PR 23765 for an example of a testcase that triggers this error.
+      if (((ssize_t) start) < 0)
+	gold_fatal(_("%s: read failed, starting offset (%#llx) less than zero"),
+		   this->filename().c_str(),
+		   static_cast<long long>(start));
+	
       bytes = this->size_ - start;
       if (static_cast<section_size_type>(bytes) >= size)
 	{