diff options
author | millert <> | 2009-06-04 20:39:13 +0000 |
---|---|---|
committer | millert <> | 2009-06-04 20:39:13 +0000 |
commit | 62cd5609d5e30c91109b27b6b996fc9ef5ed01f8 (patch) | |
tree | eb5cc22a7d1b1031747a9302fc1e566fa6419164 | |
parent | 4b01f04f286ab99a26e81be53e43f8bf46f9496d (diff) | |
download | openbsd-62cd5609d5e30c91109b27b6b996fc9ef5ed01f8.tar.gz openbsd-62cd5609d5e30c91109b27b6b996fc9ef5ed01f8.tar.bz2 openbsd-62cd5609d5e30c91109b27b6b996fc9ef5ed01f8.zip |
Don't assume that we can overwrite strings in the environment.
Someone may have passed a read-only string to putenv() (I'm looking
at you cron!).
-rw-r--r-- | src/lib/libc/stdlib/setenv.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lib/libc/stdlib/setenv.c b/src/lib/libc/stdlib/setenv.c index 242830d7b9..2e882cdbe6 100644 --- a/src/lib/libc/stdlib/setenv.c +++ b/src/lib/libc/stdlib/setenv.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: setenv.c,v 1.10 2009/06/03 15:52:16 millert Exp $ */ | 1 | /* $OpenBSD: setenv.c,v 1.11 2009/06/04 20:39:13 millert Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 1987 Regents of the University of California. | 3 | * Copyright (c) 1987 Regents of the University of California. |
4 | * All rights reserved. | 4 | * All rights reserved. |
@@ -101,11 +101,13 @@ setenv(const char *name, const char *value, int rewrite) | |||
101 | if ((C = __findenv(name, (int)(np - name), &offset)) != NULL) { | 101 | if ((C = __findenv(name, (int)(np - name), &offset)) != NULL) { |
102 | if (!rewrite) | 102 | if (!rewrite) |
103 | return (0); | 103 | return (0); |
104 | #if 0 /* XXX - existing entry may not be writable */ | ||
104 | if (strlen(C) >= l_value) { /* old larger; copy over */ | 105 | if (strlen(C) >= l_value) { /* old larger; copy over */ |
105 | while ((*C++ = *value++)) | 106 | while ((*C++ = *value++)) |
106 | ; | 107 | ; |
107 | return (0); | 108 | return (0); |
108 | } | 109 | } |
110 | #endif | ||
109 | } else { /* create new slot */ | 111 | } else { /* create new slot */ |
110 | size_t cnt; | 112 | size_t cnt; |
111 | char **P; | 113 | char **P; |