summaryrefslogtreecommitdiff
path: root/autogen-gcc9-fix-wrestrict.patch
blob: 09220e84dc2c4c4febdbd3c3da723bd474ba55ee (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
50
51
52
53
54
55
56
Origin: https://build.opensuse.org/package/show/openSUSE:Factory/autogen
Author: Martin Liška <mliska@suse.cz>
Bug-Suse: https://bugzilla.suse.com/show_bug.cgi?id=1125772
Forwarded: https://sourceforge.net/p/autogen/bugs/193/
Comment: Superseded by 132576313e66ee270ebb70f82afdaeacec1f2fc1

diff --git a/compat/pathfind.c b/compat/pathfind.c
index 5c477ca..6a4eeb5 100644
--- a/compat/pathfind.c
+++ b/compat/pathfind.c
@@ -136,6 +136,18 @@ make_absolute( char const * string, char const * dot_path )
     return result;
 }
 
+/*
+ * Proccess strcpy for overlapping memory locations.
+ */
+static char*
+strcpy_overlapping ( char *d, const char *s)
+{
+  unsigned n = strlen ( s );
+  memmove ( d, s, n + 1 );
+  return d;
+}
+
+
 /*
  * Canonicalize PATH, and return a  new path.  The new path differs from
  * PATH in that:
@@ -182,7 +194,7 @@ canonicalize_pathname( char *path )
         if ((start + 1) != i && (start != 0 || i != 2))
 #endif /* apollo */
         {
-            strcpy( result + start + 1, result + i );
+            strcpy_overlapping( result + start + 1, result + i );
             i = start + 1;
         }
 
@@ -201,7 +213,7 @@ canonicalize_pathname( char *path )
         if (result[i] == '.') {
             /* Handle `./'. */
             if (result[i + 1] == '/') {
-                strcpy( result + i, result + i + 1 );
+                strcpy_overlapping( result + i, result + i + 1 );
                 i = (start < 0) ? 0 : start;
                 continue;
             }
@@ -211,7 +223,7 @@ canonicalize_pathname( char *path )
                 (result[i + 2] == '/' || !result[i + 2])) {
                 while (--start > -1 && result[start] != '/')
                     ;
-                strcpy( result + start + 1, result + i + 2 );
+                strcpy_overlapping( result + start + 1, result + i + 2 );
                 i = (start < 0) ? 0 : start;
                 continue;
             }