diff options
Diffstat (limited to 'src/lib/libc/stdlib/setenv.c')
| -rw-r--r-- | src/lib/libc/stdlib/setenv.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/lib/libc/stdlib/setenv.c b/src/lib/libc/stdlib/setenv.c index a36669888d..fc7c67a5db 100644 --- a/src/lib/libc/stdlib/setenv.c +++ b/src/lib/libc/stdlib/setenv.c | |||
| @@ -32,8 +32,7 @@ | |||
| 32 | */ | 32 | */ |
| 33 | 33 | ||
| 34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
| 35 | /*static char *sccsid = "from: @(#)setenv.c 5.6 (Berkeley) 6/4/91";*/ | 35 | static char *rcsid = "$OpenBSD: setenv.c,v 1.4 2001/07/09 06:57:45 deraadt Exp $"; |
| 36 | static char *rcsid = "$Id: setenv.c,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $"; | ||
| 37 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
| 38 | 37 | ||
| 39 | #include <stdlib.h> | 38 | #include <stdlib.h> |
| @@ -63,7 +62,8 @@ setenv(name, value, rewrite) | |||
| 63 | if (!rewrite) | 62 | if (!rewrite) |
| 64 | return (0); | 63 | return (0); |
| 65 | if (strlen(C) >= l_value) { /* old larger; copy over */ | 64 | if (strlen(C) >= l_value) { /* old larger; copy over */ |
| 66 | while (*C++ = *value++); | 65 | while ((*C++ = *value++)) |
| 66 | ; | ||
| 67 | return (0); | 67 | return (0); |
| 68 | } | 68 | } |
| 69 | } else { /* create new slot */ | 69 | } else { /* create new slot */ |
| @@ -72,10 +72,11 @@ setenv(name, value, rewrite) | |||
| 72 | 72 | ||
| 73 | for (P = environ, cnt = 0; *P; ++P, ++cnt); | 73 | for (P = environ, cnt = 0; *P; ++P, ++cnt); |
| 74 | if (alloced) { /* just increase size */ | 74 | if (alloced) { /* just increase size */ |
| 75 | environ = (char **)realloc((char *)environ, | 75 | P = (char **)realloc((void *)environ, |
| 76 | (size_t)(sizeof(char *) * (cnt + 2))); | 76 | (size_t)(sizeof(char *) * (cnt + 2))); |
| 77 | if (!environ) | 77 | if (!P) |
| 78 | return (-1); | 78 | return (-1); |
| 79 | environ = P; | ||
| 79 | } | 80 | } |
| 80 | else { /* get new space */ | 81 | else { /* get new space */ |
| 81 | alloced = 1; /* copy old entries into it */ | 82 | alloced = 1; /* copy old entries into it */ |
| @@ -95,7 +96,7 @@ setenv(name, value, rewrite) | |||
| 95 | return (-1); | 96 | return (-1); |
| 96 | for (C = environ[offset]; (*C = *name++) && *C != '='; ++C) | 97 | for (C = environ[offset]; (*C = *name++) && *C != '='; ++C) |
| 97 | ; | 98 | ; |
| 98 | for (*C++ = '='; *C++ = *value++; ) | 99 | for (*C++ = '='; (*C++ = *value++); ) |
| 99 | ; | 100 | ; |
| 100 | return (0); | 101 | return (0); |
| 101 | } | 102 | } |
