summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/setenv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/stdlib/setenv.c')
-rw-r--r--src/lib/libc/stdlib/setenv.c7
1 files changed, 4 insertions, 3 deletions
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) {