Gentoo Archives: gentoo-commits

From: "Fabian Groffen (grobian)" <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-alt r1645 - trunk/toolchain-prefix-wrapper/ld
Date: Sat, 21 Mar 2009 14:40:44
Message-Id: E1Ll2NN-0003E1-Fw@stork.gentoo.org
1 Author: grobian
2 Date: 2009-03-21 14:40:41 +0000 (Sat, 21 Mar 2009)
3 New Revision: 1645
4
5 Modified:
6 trunk/toolchain-prefix-wrapper/ld/gnuplugin.c
7 Log:
8 alloca inside a loop is just too scary, use a fixed buffer instead
9
10 Modified: trunk/toolchain-prefix-wrapper/ld/gnuplugin.c
11 ===================================================================
12 --- trunk/toolchain-prefix-wrapper/ld/gnuplugin.c 2009-03-21 14:28:47 UTC (rev 1644)
13 +++ trunk/toolchain-prefix-wrapper/ld/gnuplugin.c 2009-03-21 14:40:41 UTC (rev 1645)
14 @@ -13,7 +13,7 @@
15 #include <sys/types.h>
16 #include <sys/stat.h>
17 #include <unistd.h>
18 -#include <alloca.h>
19 +#include <sys/param.h>
20
21 #if defined(__cplusplus)
22 extern "C" {
23 @@ -35,6 +35,7 @@
24 int argLength;
25 char const *rpathArg = NULL;
26 int rpathArgLen = 0;
27 + char str[MAXPATHLEN + 1];
28
29 do { /* dummy loop */
30 err = -1;
31 @@ -91,12 +92,12 @@
32 if (curr == argBuffer && rpathArg == _R) {
33 struct stat sbuf;
34 int rv;
35 - char *path = (char *)curr;
36 + const char *path = curr;
37 if (*next == ':') {
38 /* terminate the string in case of ':' */
39 - path = alloca(sizeof(char) * (next - curr + 1));
40 - memcpy(path, curr, next - curr);
41 - path[next - curr] = '\0';
42 + memcpy(str, curr, next - curr);
43 + str[next - curr] = '\0';
44 + path = str;
45 }
46 rv = stat(path, &sbuf);
47 /* if argument to "-R" is not a directory, then