summaryrefslogtreecommitdiff
path: root/lib/libc/nls/catopen.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-08-26 00:17:29 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-08-26 00:17:29 +0000
commit1ac73728e4fb9188de899a35eb12fe3adad86b1d (patch)
tree214153b9363774b96c668b1dc2cfb1b9c7307b3b /lib/libc/nls/catopen.c
parent05a1c82cea94423f31eeffcde116ad3b225de98e (diff)
use issetugid() to protect against bad getenv
Diffstat (limited to 'lib/libc/nls/catopen.c')
-rw-r--r--lib/libc/nls/catopen.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/libc/nls/catopen.c b/lib/libc/nls/catopen.c
index 38b9abd36b9..28dd2f69408 100644
--- a/lib/libc/nls/catopen.c
+++ b/lib/libc/nls/catopen.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: catopen.c,v 1.5 1996/08/19 08:30:09 tholo Exp $";
+static char rcsid[] = "$OpenBSD: catopen.c,v 1.6 1996/08/26 00:17:20 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#define _NLS_PRIVATE
@@ -72,15 +72,13 @@ _catopen(name, oflag)
return (nl_catd) -1;
/* absolute or relative path? */
- if (strchr (name, '/'))
+ if (strchr(name, '/'))
return load_msgcat(name);
- if ((nlspath = getenv ("NLSPATH")) == NULL) {
+ if (issetugid() != 0 || (nlspath = getenv("NLSPATH")) == NULL)
nlspath = NLS_DEFAULT_PATH;
- }
- if ((lang = getenv ("LANG")) == NULL) {
+ if ((lang = getenv("LANG")) == NULL)
lang = NLS_DEFAULT_LANG;
- }
s = nlspath;
t = tmppath;
@@ -135,7 +133,7 @@ load_msgcat(path)
void *data;
int fd;
- if ((fd = open (path, O_RDONLY)) == -1)
+ if ((fd = open(path, O_RDONLY)) == -1)
return (nl_catd) -1;
if (fstat(fd, &st) != 0) {
@@ -156,7 +154,7 @@ load_msgcat(path)
return (nl_catd) -1;
}
- if ((catd = malloc (sizeof (*catd))) == 0) {
+ if ((catd = malloc(sizeof (*catd))) == 0) {
munmap(data, (size_t) st.st_size);
return (nl_catd) -1;
}