summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/binutils/binutils/0003-CVE-2021-20197.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/binutils/binutils/0003-CVE-2021-20197.patch')
-rw-r--r--meta/recipes-devtools/binutils/binutils/0003-CVE-2021-20197.patch171
1 files changed, 0 insertions, 171 deletions
diff --git a/meta/recipes-devtools/binutils/binutils/0003-CVE-2021-20197.patch b/meta/recipes-devtools/binutils/binutils/0003-CVE-2021-20197.patch
deleted file mode 100644
index 082b28b29c..0000000000
--- a/meta/recipes-devtools/binutils/binutils/0003-CVE-2021-20197.patch
+++ /dev/null
@@ -1,171 +0,0 @@
1From 8b69e61d4be276bb862698aaafddc3e779d23c8f Mon Sep 17 00:00:00 2001
2From: Alan Modra <amodra@gmail.com>
3Date: Tue, 23 Feb 2021 09:37:39 +1030
4Subject: [PATCH] PR27456, lstat in rename.c on MinGW
5
6 PR 27456
7 * rename.c: Tidy throughout.
8 (smart_rename): Always copy. Remove windows specific code.
9
10(cherry picked from commit cca8873dd5a6015d5557ea44bc1ea9c252435a29)
11
12Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8b69e61d4be276bb862698aaafddc3e779d23c8f]
13CVE: CVE-2021-20197
14Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
15---
16 binutils/rename.c | 111 ++++++++++++++-------------------------------
17 2 files changed, 40 insertions(+), 76 deletions(-)
18
19diff --git a/binutils/rename.c b/binutils/rename.c
20index 2ff092ee22b..72a9323d72c 100644
21--- a/binutils/rename.c
22+++ b/binutils/rename.c
23@@ -24,14 +24,9 @@
24
25 #ifdef HAVE_GOOD_UTIME_H
26 #include <utime.h>
27-#else /* ! HAVE_GOOD_UTIME_H */
28-#ifdef HAVE_UTIMES
29+#elif defined HAVE_UTIMES
30 #include <sys/time.h>
31-#endif /* HAVE_UTIMES */
32-#endif /* ! HAVE_GOOD_UTIME_H */
33-
34-#if ! defined (_WIN32) || defined (__CYGWIN32__)
35-static int simple_copy (const char *, const char *);
36+#endif
37
38 /* The number of bytes to copy at once. */
39 #define COPY_BUF 8192
40@@ -82,7 +77,6 @@ simple_copy (const char *from, const char *to)
41 }
42 return 0;
43 }
44-#endif /* __CYGWIN32__ or not _WIN32 */
45
46 /* Set the times of the file DESTINATION to be the same as those in
47 STATBUF. */
48@@ -91,87 +85,52 @@ void
49 set_times (const char *destination, const struct stat *statbuf)
50 {
51 int result;
52-
53- {
54 #ifdef HAVE_GOOD_UTIME_H
55- struct utimbuf tb;
56-
57- tb.actime = statbuf->st_atime;
58- tb.modtime = statbuf->st_mtime;
59- result = utime (destination, &tb);
60-#else /* ! HAVE_GOOD_UTIME_H */
61-#ifndef HAVE_UTIMES
62- long tb[2];
63-
64- tb[0] = statbuf->st_atime;
65- tb[1] = statbuf->st_mtime;
66- result = utime (destination, tb);
67-#else /* HAVE_UTIMES */
68- struct timeval tv[2];
69-
70- tv[0].tv_sec = statbuf->st_atime;
71- tv[0].tv_usec = 0;
72- tv[1].tv_sec = statbuf->st_mtime;
73- tv[1].tv_usec = 0;
74- result = utimes (destination, tv);
75-#endif /* HAVE_UTIMES */
76-#endif /* ! HAVE_GOOD_UTIME_H */
77- }
78+ struct utimbuf tb;
79+
80+ tb.actime = statbuf->st_atime;
81+ tb.modtime = statbuf->st_mtime;
82+ result = utime (destination, &tb);
83+#elif defined HAVE_UTIMES
84+ struct timeval tv[2];
85+
86+ tv[0].tv_sec = statbuf->st_atime;
87+ tv[0].tv_usec = 0;
88+ tv[1].tv_sec = statbuf->st_mtime;
89+ tv[1].tv_usec = 0;
90+ result = utimes (destination, tv);
91+#else
92+ long tb[2];
93+
94+ tb[0] = statbuf->st_atime;
95+ tb[1] = statbuf->st_mtime;
96+ result = utime (destination, tb);
97+#endif
98
99 if (result != 0)
100 non_fatal (_("%s: cannot set time: %s"), destination, strerror (errno));
101 }
102
103-/* Rename FROM to TO, copying if TO exists. TARGET_STAT has the file status
104- that, if non-NULL, is used to fix up timestamps after rename. Return 0 if
105- ok, -1 if error. */
106+/* Copy FROM to TO. TARGET_STAT has the file status that, if non-NULL,
107+ is used to fix up timestamps. Return 0 if ok, -1 if error.
108+ At one time this function renamed files, but file permissions are
109+ tricky to update given the number of different schemes used by
110+ various systems. So now we just copy. */
111
112 int
113 smart_rename (const char *from, const char *to,
114- struct stat *target_stat ATTRIBUTE_UNUSED)
115+ struct stat *target_stat)
116 {
117- int ret = 0;
118- struct stat to_stat;
119- bfd_boolean exists;
120-
121- exists = lstat (to, &to_stat) == 0;
122-
123-#if defined (_WIN32) && !defined (__CYGWIN32__)
124- /* Win32, unlike unix, will not erase `to' in `rename(from, to)' but
125- fail instead. Also, chown is not present. */
126-
127- if (exists)
128- remove (to);
129+ int ret;
130
131- ret = rename (from, to);
132+ ret = simple_copy (from, to);
133 if (ret != 0)
134- {
135- /* We have to clean up here. */
136- non_fatal (_("unable to rename '%s'; reason: %s"), to, strerror (errno));
137- unlink (from);
138- }
139-#else
140- /* Avoid a full copy and use rename if TO does not exist. */
141- if (!exists)
142- {
143- if ((ret = rename (from, to)) != 0)
144- {
145- /* We have to clean up here. */
146- non_fatal (_("unable to rename '%s'; reason: %s"), to, strerror (errno));
147- unlink (from);
148- }
149- }
150- else
151- {
152- ret = simple_copy (from, to);
153- if (ret != 0)
154- non_fatal (_("unable to copy file '%s'; reason: %s"), to, strerror (errno));
155+ non_fatal (_("unable to copy file '%s'; reason: %s"),
156+ to, strerror (errno));
157
158- if (target_stat != NULL)
159- set_times (to, target_stat);
160- unlink (from);
161- }
162-#endif /* _WIN32 && !__CYGWIN32__ */
163+ if (target_stat != NULL)
164+ set_times (to, target_stat);
165+ unlink (from);
166
167 return ret;
168 }
169--
1702.31.1
171