summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/stdlib/getenv.38
-rw-r--r--src/lib/libc/stdlib/setenv.c7
2 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/libc/stdlib/getenv.3 b/src/lib/libc/stdlib/getenv.3
index 1654d4257c..5a219a5c03 100644
--- a/src/lib/libc/stdlib/getenv.3
+++ b/src/lib/libc/stdlib/getenv.3
@@ -29,9 +29,9 @@
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE. 30.\" SUCH DAMAGE.
31.\" 31.\"
32.\" $OpenBSD: getenv.3,v 1.22 2022/07/25 02:25:55 jsg Exp $ 32.\" $OpenBSD: getenv.3,v 1.23 2022/08/08 22:40:03 millert Exp $
33.\" 33.\"
34.Dd $Mdocdate: July 25 2022 $ 34.Dd $Mdocdate: August 8 2022 $
35.Dt GETENV 3 35.Dt GETENV 3
36.Os 36.Os
37.Sh NAME 37.Sh NAME
@@ -133,6 +133,10 @@ function was passed a
133.Ar string 133.Ar string
134that did not contain an 134that did not contain an
135.Sq = 135.Sq =
136character, or was passed a
137.Ar string
138that started with the
139.Sq =
136character. 140character.
137.It Bq Er ENOMEM 141.It Bq Er ENOMEM
138The 142The
diff --git a/src/lib/libc/stdlib/setenv.c b/src/lib/libc/stdlib/setenv.c
index 15c550ba30..fc8e5b677f 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.19 2016/09/21 04:38:56 guenther Exp $ */ 1/* $OpenBSD: setenv.c,v 1.20 2022/08/08 22:40:03 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.
@@ -48,9 +48,10 @@ putenv(char *str)
48 48
49 for (cp = str; *cp && *cp != '='; ++cp) 49 for (cp = str; *cp && *cp != '='; ++cp)
50 ; 50 ;
51 if (*cp != '=') { 51 if (cp == str || *cp != '=') {
52 /* '=' is the first character of string or is missing. */
52 errno = EINVAL; 53 errno = EINVAL;
53 return (-1); /* missing `=' in string */ 54 return (-1);
54 } 55 }
55 56
56 if (__findenv(str, (int)(cp - str), &offset) != NULL) { 57 if (__findenv(str, (int)(cp - str), &offset) != NULL) {