summaryrefslogtreecommitdiff
path: root/lib/csu/sparc/crt0.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-02-28 18:05:52 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-02-28 18:05:52 +0000
commitc4ab57aad282b1af1cfaea168eba167c9265c587 (patch)
tree0b2f4bad1ef790abf5fdd09a6632393fd4ed9524 /lib/csu/sparc/crt0.c
parent1e988d2ffc39487d5063a70a1f09e5c4bdad7918 (diff)
copy basename of argv[0] to bss for __progname, so that large stack smash
does not make propolice reporting ineffective; millert miod ok
Diffstat (limited to 'lib/csu/sparc/crt0.c')
-rw-r--r--lib/csu/sparc/crt0.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/csu/sparc/crt0.c b/lib/csu/sparc/crt0.c
index 3d5a004eb65..6cc0c37dad2 100644
--- a/lib/csu/sparc/crt0.c
+++ b/lib/csu/sparc/crt0.c
@@ -36,6 +36,7 @@
*/
#include <stdlib.h>
+#include <limits.h>
void ___start(int, char **, char **, void (*cleanup)(void), void *);
@@ -62,6 +63,7 @@ _start:
char **environ;
char *__progname = "";
+char __progname_storage[NAME_MAX+1];
#ifdef MCRT0
extern void monstartup(u_long, u_long);
@@ -75,6 +77,8 @@ void
___start(int argc, char **argv, char **envp, void (*cleanup)(void),
void *obj)
{
+ char *s;
+
environ = envp;
if ((__progname = argv[0]) != NULL) { /* NULL ptr if argc = 0 */
@@ -82,6 +86,11 @@ ___start(int argc, char **argv, char **envp, void (*cleanup)(void),
__progname = argv[0];
else
__progname++;
+ for (s = __progname_storage; *__progname &&
+ s < &__progname_storage[sizeof __progname_storage - 1]; )
+ *s++ = *__progname++;
+ *s = '\0';
+ __progname = __progname_storage;
}
#ifdef MCRT0