diff options
-rw-r--r-- | lib/csu/alpha/crt0.c | 12 | ||||
-rw-r--r-- | lib/csu/common.h | 4 | ||||
-rw-r--r-- | lib/csu/hppa/crt0.c | 12 | ||||
-rw-r--r-- | lib/csu/i386/crt0.c | 10 | ||||
-rw-r--r-- | lib/csu/m68k/crt0.c | 13 | ||||
-rw-r--r-- | lib/csu/m88k/crt0.c | 13 | ||||
-rw-r--r-- | lib/csu/powerpc/crt0.c | 4 | ||||
-rw-r--r-- | lib/csu/sparc/crt0.c | 9 | ||||
-rw-r--r-- | lib/csu/sparc64/crt0.c | 10 | ||||
-rw-r--r-- | lib/csu/vax/crt0.c | 13 |
10 files changed, 80 insertions, 20 deletions
diff --git a/lib/csu/alpha/crt0.c b/lib/csu/alpha/crt0.c index b3ae7d48bb1..34fd45e1b67 100644 --- a/lib/csu/alpha/crt0.c +++ b/lib/csu/alpha/crt0.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crt0.c,v 1.7 2002/02/16 21:27:20 millert Exp $ */ +/* $OpenBSD: crt0.c,v 1.8 2003/02/28 18:05:51 deraadt Exp $ */ /* $NetBSD: crt0.c,v 1.1 1996/09/12 16:59:02 cgd Exp $ */ /* * Copyright (c) 1995 Christopher G. Demetriou @@ -32,15 +32,17 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: crt0.c,v 1.7 2002/02/16 21:27:20 millert Exp $"; +static char rcsid[] = "$OpenBSD: crt0.c,v 1.8 2003/02/28 18:05:51 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdlib.h> +#include <limits.h> static char *_strrchr(char *, char); char **environ; char *__progname = ""; +char __progname_storage[NAME_MAX+1]; #ifdef MCRT0 extern void monstartup(u_long, u_long); @@ -56,6 +58,7 @@ __start(sp, cleanup, obj) { long argc; char **argv, *namep; + char *s; argc = *(long *)sp; argv = sp + 1; @@ -66,6 +69,11 @@ __start(sp, cleanup, obj) __progname = namep; else __progname++; + for (s = __progname_storage; *__progname && + s < &__progname_storage[sizeof __progname_storage - 1]; ) + *s++ = *__progname++; + *s = '\0'; + __progname = __progname_storage; } #ifdef MCRT0 diff --git a/lib/csu/common.h b/lib/csu/common.h index 596b7cff5e7..23d51f377a7 100644 --- a/lib/csu/common.h +++ b/lib/csu/common.h @@ -1,4 +1,4 @@ -/* $OpenBSD: common.h,v 1.6 2002/09/17 21:16:01 deraadt Exp $ */ +/* $OpenBSD: common.h,v 1.7 2003/02/28 18:05:48 deraadt Exp $ */ /* $NetBSD: common.h,v 1.3 1995/06/15 21:41:48 pk Exp $ */ /* @@ -33,6 +33,7 @@ */ #include <string.h> +#include <limits.h> #ifdef DYNAMIC @@ -92,6 +93,7 @@ char **environ; int errno; static char empty[1]; char *__progname = empty; +char __progname_storage[NAME_MAX+1]; #ifndef DYNAMIC #define _strrchr strrchr #endif diff --git a/lib/csu/hppa/crt0.c b/lib/csu/hppa/crt0.c index bcf45f5111d..45ae4d796b9 100644 --- a/lib/csu/hppa/crt0.c +++ b/lib/csu/hppa/crt0.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crt0.c,v 1.5 2003/01/16 19:15:38 mickey Exp $ */ +/* $OpenBSD: crt0.c,v 1.6 2003/02/28 18:05:51 deraadt Exp $ */ /* * Copyright (c) 2001 Michael Shalayeff @@ -35,13 +35,13 @@ int global __asm ("$global$") = 0; int sh_func_adrs __asm ("$$sh_func_adrs") = 0; #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$OpenBSD: crt0.c,v 1.5 2003/01/16 19:15:38 mickey Exp $"; +static const char rcsid[] = "$OpenBSD: crt0.c,v 1.6 2003/02/28 18:05:51 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ -#include <stdlib.h> #include <sys/syscall.h> #include <sys/fcntl.h> #include <sys/exec.h> +#include <stdlib.h> #include <paths.h> #include "common.h" @@ -75,6 +75,7 @@ __start(sp, cleanup, obj) { struct ps_strings *arginfo = (struct ps_strings *)sp; char **argv, *namep; + char *s; __asm __volatile (".import $global$, data\n\t" "ldil L%%$global$, %%r27\n\t" @@ -87,6 +88,11 @@ __start(sp, cleanup, obj) __progname = namep; else __progname++; + for (s = __progname_storage; *__progname && + s < &__progname_storage[sizeof __progname_storage - 1]; ) + *s++ = *__progname++; + *s = '\0'; + __progname = __progname_storage; } #ifdef MCRT0 diff --git a/lib/csu/i386/crt0.c b/lib/csu/i386/crt0.c index 19390e7c840..22bbfddf5e7 100644 --- a/lib/csu/i386/crt0.c +++ b/lib/csu/i386/crt0.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crt0.c,v 1.8 2002/09/17 21:16:01 deraadt Exp $ */ +/* $OpenBSD: crt0.c,v 1.9 2003/02/28 18:05:51 deraadt Exp $ */ /* $NetBSD: crt0.c,v 1.20 1995/06/03 13:16:08 pk Exp $ */ /* @@ -34,7 +34,7 @@ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: crt0.c,v 1.8 2002/09/17 21:16:01 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: crt0.c,v 1.9 2003/02/28 18:05:51 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -58,6 +58,7 @@ start() */ register struct kframe *kfp; register char **argv, *ap; + char *s; #ifdef lint kfp = 0; @@ -74,6 +75,11 @@ start() __progname = ap; else ++__progname; + for (s = __progname_storage; *__progname && + s < &__progname_storage[sizeof __progname_storage - 1]; ) + *s++ = *__progname++; + *s = '\0'; + __progname = __progname_storage; } #ifdef DYNAMIC diff --git a/lib/csu/m68k/crt0.c b/lib/csu/m68k/crt0.c index 9484cf5e7cf..b4fd36cec96 100644 --- a/lib/csu/m68k/crt0.c +++ b/lib/csu/m68k/crt0.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crt0.c,v 1.7 2002/09/17 21:16:01 deraadt Exp $ */ +/* $OpenBSD: crt0.c,v 1.8 2003/02/28 18:05:51 deraadt Exp $ */ /* $NetBSD: crt0.c,v 1.14 1995/06/03 13:16:11 pk Exp $ */ /* * Copyright (c) 1993 Paul Kranenburg @@ -33,7 +33,7 @@ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: crt0.c,v 1.7 2002/09/17 21:16:01 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: crt0.c,v 1.8 2003/02/28 18:05:51 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -57,6 +57,7 @@ start() */ register struct kframe *kfp; register char **argv, *ap; + char *s; #ifdef lint kfp = 0; @@ -67,11 +68,17 @@ start() argv = &kfp->kargv[0]; environ = argv + kfp->kargc + 1; - if (ap = argv[0]) + if (ap = argv[0]) { if ((__progname = _strrchr(ap, '/')) == NULL) __progname = ap; else ++__progname; + for (s = __progname_storage; *__progname && + s < &__progname_storage[sizeof __progname_storage - 1]; ) + *s++ = *__progname++; + *s = '\0'; + __progname = __progname_storage; + } #ifdef DYNAMIC /* ld(1) convention: if DYNAMIC = 0 then statically linked */ diff --git a/lib/csu/m88k/crt0.c b/lib/csu/m88k/crt0.c index f458d5df897..9e24c29de35 100644 --- a/lib/csu/m88k/crt0.c +++ b/lib/csu/m88k/crt0.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crt0.c,v 1.1 2001/06/26 22:42:55 miod Exp $ */ +/* $OpenBSD: crt0.c,v 1.2 2003/02/28 18:05:51 deraadt Exp $ */ /* * Mach Operating System @@ -28,7 +28,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: crt0.c,v 1.1 2001/06/26 22:42:55 miod Exp $"; +static char rcsid[] = "$OpenBSD: crt0.c,v 1.2 2003/02/28 18:05:51 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -99,14 +99,21 @@ __crt0_real_start(int argc, char *argv[], char *envp[]) register char *ap; volatile int a = 0; extern int end; + char *s; environ = envp; /* environ is for the user that can't get at 'envp' */ - if (ap = argv[0]) + if (ap = argv[0]) { if ((__progname = _strrchr(ap, '/')) == NULL) __progname = ap; else ++__progname; + for (s = __progname_storage; *__progname && + s < &__progname_storage[sizeof __progname_storage - 1]; ) + *s++ = *__progname++; + *s = '\0'; + __progname = __progname_storage; + } asm ("__callmain:"); /* Defined for the benefit of debuggers */ exit(main(argc, argv, environ)); diff --git a/lib/csu/powerpc/crt0.c b/lib/csu/powerpc/crt0.c index 6491ab65ade..4bfd73b5c2c 100644 --- a/lib/csu/powerpc/crt0.c +++ b/lib/csu/powerpc/crt0.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crt0.c,v 1.1 2003/02/26 18:50:35 drahn Exp $ */ +/* $OpenBSD: crt0.c,v 1.2 2003/02/28 18:05:51 deraadt Exp $ */ /* $NetBSD: crt0.c,v 1.1 1996/09/12 16:59:02 cgd Exp $ */ /* * Copyright (c) 1995 Christopher G. Demetriou @@ -36,7 +36,7 @@ char **environ; char * __progname = ""; -char __progname_storage[MAXPATHLEN]; +char __progname_storage[NAME_MAX+1]; #ifdef MCRT0 extern void monstartup(u_long, u_long); 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 diff --git a/lib/csu/sparc64/crt0.c b/lib/csu/sparc64/crt0.c index 5c776bc708f..68457bfba42 100644 --- a/lib/csu/sparc64/crt0.c +++ b/lib/csu/sparc64/crt0.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crt0.c,v 1.4 2002/02/17 19:42:22 millert Exp $ */ +/* $OpenBSD: crt0.c,v 1.5 2003/02/28 18:05:51 deraadt Exp $ */ /* * Copyright (c) 1995 Christopher G. Demetriou @@ -32,11 +32,13 @@ */ #include <stdlib.h> +#include <limits.h> static char *_strrchr(char *, char); char **environ; char *__progname = ""; +char __progname_storage[NAME_MAX+1]; #ifdef MCRT0 extern void monstartup(u_long, u_long); @@ -66,6 +68,7 @@ ___start(char **sp, void (*cleanup)(void), const void *obj) { long argc; char **argv, *namep; + char *s; argc = *(long *)sp; argv = sp + 1; @@ -76,6 +79,11 @@ ___start(char **sp, void (*cleanup)(void), const void *obj) __progname = namep; else __progname++; + for (s = __progname_storage; *__progname && + s < &__progname_storage[sizeof __progname_storage - 1]; ) + *s++ = *__progname++; + *s = '\0'; + __progname = __progname_storage; } #ifdef MCRT0 diff --git a/lib/csu/vax/crt0.c b/lib/csu/vax/crt0.c index 9881dbb69f2..47db33744ed 100644 --- a/lib/csu/vax/crt0.c +++ b/lib/csu/vax/crt0.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crt0.c,v 1.7 2002/09/17 21:16:01 deraadt Exp $ */ +/* $OpenBSD: crt0.c,v 1.8 2003/02/28 18:05:51 deraadt Exp $ */ /* $NetBSD: crt0.c,v 1.1.2.1 1995/10/15 19:40:04 ragge Exp $ */ /* * Copyright (c) 1993 Paul Kranenburg @@ -33,7 +33,7 @@ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: crt0.c,v 1.7 2002/09/17 21:16:01 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: crt0.c,v 1.8 2003/02/28 18:05:51 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -57,6 +57,7 @@ start() */ register struct kframe *kfp; register char **argv, *ap; + char *s; #ifdef lint kfp = 0; @@ -68,11 +69,17 @@ start() argv = &kfp->kargv[0]; environ = argv + kfp->kargc + 1; - if (ap = argv[0]) + if (ap = argv[0]) { if ((__progname = _strrchr(ap, '/')) == NULL) __progname = ap; else ++__progname; + for (s = __progname_storage; *__progname && + s < &__progname_storage[sizeof __progname_storage - 1]; ) + *s++ = *__progname++; + *s = '\0'; + __progname = __progname_storage; + } #ifdef DYNAMIC /* ld(1) convention: if DYNAMIC = 0 then statically linked */ |