summaryrefslogtreecommitdiff
path: root/sysutils/prelink/files/patch-src-gather.c
blob: 9470854776b7fda9ec8dabf9d52a195067215fd0 (plain) (blame)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
diff -Nur src/gather.c src/gather.c
--- src/gather.c	2013-02-19 23:54:34.000000000 +0200
+++ src/gather.c	2013-02-19 23:50:31.000000000 +0200
@@ -235,7 +235,8 @@
 	    }
 	}
 
-      depends[ndepends] = strdupa (p);
+      depends[ndepends] = alloca (strlen(p) + 1);
+      strcpy(depends[ndepends], p);
       ++ndepends;
     } while (!feof (f));
 
@@ -495,7 +496,11 @@
 }
 
 static int
+#if __LINUX__
 gather_exec (DSO *dso, const struct stat64 *st)
+#else
+gather_exec (DSO *dso, const struct stat *st)
+#endif
 {
   int i, j;
   Elf_Data *data;
@@ -635,7 +640,11 @@
 }
 
 static int
+#if __LINUX__
 gather_func (const char *name, const struct stat64 *st, int type,
+#else
+gather_func (const char *name, const struct stat *st, int type,
+#endif
 	     struct FTW *ftwp)
 {
   unsigned char e_ident [sizeof (Elf64_Ehdr) + sizeof (Elf64_Phdr)];
@@ -901,7 +910,11 @@
 }
 
 static int
+#if __LINUX__
 gather_binlib (const char *name, const struct stat64 *st)
+#else
+gather_binlib (const char *name, const struct stat *st)
+#endif
 {
   unsigned char e_ident [EI_NIDENT + 2];
   int fd, type;
@@ -1014,9 +1027,17 @@
 int
 gather_object (const char *name, int deref, int onefs)
 {
+#if __LINUX__
   struct stat64 st;
+#else
+  struct stat st;
+#endif
 
+#if __LINUX__
   if (stat64 (name, &st) < 0)
+#else
+  if (stat (name, &st) < 0)
+#endif
     {
       if (implicit)
 	return 0;
@@ -1039,7 +1060,11 @@
       if (!all && implicit && ! deref)
 	return 0;
       ++implicit;
+#if __LINUX__
       ret = nftw64 (name, gather_func, 20, flags | FTW_ACTIONRETVAL);
+#else
+      ret = nftw (name, gather_func, 20, flags | FTW_ACTIONRETVAL);
+#endif
       --implicit;
       if (ret < 0)
 	error (0, errno, "Failed searching %s", name);
@@ -1300,9 +1325,17 @@
   const char *canon_name;
   struct prelink_dir *path;
   size_t len;
+#if __LINUX__
   struct stat64 st;
+#else
+  struct stat st;
+#endif
 
+#if __LINUX__
   if (stat64 (name, &st) < 0)
+#else
+  if (stat (name, &st) < 0)
+#endif
     {
       if (implicit)
 	return 0;
@@ -1421,7 +1454,11 @@
 	{
 	  glob_t g;
 
+#ifdef GLOB_PERIOD
 	  if (!glob (p, GLOB_BRACE | GLOB_PERIOD, NULL, &g))
+#else
+	  if (!glob (p, GLOB_BRACE, NULL, &g))
+#endif
 	    {
 	      size_t n;