diff options
author | Stefan Sperling <stsp@cvs.openbsd.org> | 2011-03-15 22:27:49 +0000 |
---|---|---|
committer | Stefan Sperling <stsp@cvs.openbsd.org> | 2011-03-15 22:27:49 +0000 |
commit | a950c8e61c750b66595b846c759af2e0fce22163 (patch) | |
tree | e94d8d1200910d0d17aeb4add2da2c2bc1c1e4dc | |
parent | 9c5e7980c27933fd93cf4fdae7ee9722775c052c (diff) |
Remove evaluation of PATH_LOCALE environment variable because it can be
abused to cause an integer overflow and serves no real purpose.
Found by Alexander Schrijver.
ok millert deraadt
-rw-r--r-- | lib/libc/locale/rune.h | 3 | ||||
-rw-r--r-- | lib/libc/locale/runetable.c | 2 | ||||
-rw-r--r-- | lib/libc/locale/setlocale.c | 9 | ||||
-rw-r--r-- | lib/libc/locale/setrunelocale.c | 5 |
4 files changed, 6 insertions, 13 deletions
diff --git a/lib/libc/locale/rune.h b/lib/libc/locale/rune.h index 849c99f1345..f3c93936133 100644 --- a/lib/libc/locale/rune.h +++ b/lib/libc/locale/rune.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rune.h,v 1.1 2005/08/07 10:16:23 espie Exp $ */ +/* $OpenBSD: rune.h,v 1.2 2011/03/15 22:27:48 stsp Exp $ */ /* $NetBSD: rune.h,v 1.9 2003/08/07 16:43:04 agc Exp $ */ /*- @@ -76,6 +76,5 @@ extern size_t __mb_len_max_runtime; extern _RuneLocale _DefaultRuneLocale; extern _RuneLocale *_CurrentRuneLocale; -extern char *_PathLocale; #endif /*! _RUNE_H_ */ diff --git a/lib/libc/locale/runetable.c b/lib/libc/locale/runetable.c index 07dce4ba2b0..d78c691ccc3 100644 --- a/lib/libc/locale/runetable.c +++ b/lib/libc/locale/runetable.c @@ -403,5 +403,3 @@ _RuneLocale _DefaultRuneLocale = { }; _RuneLocale *_CurrentRuneLocale = &_DefaultRuneLocale; - -char *_PathLocale; diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c index cb4c5269a66..daba2fec108 100644 --- a/lib/libc/locale/setlocale.c +++ b/lib/libc/locale/setlocale.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setlocale.c,v 1.17 2007/11/28 10:24:38 chl Exp $ */ +/* $OpenBSD: setlocale.c,v 1.18 2011/03/15 22:27:48 stsp Exp $ */ /* * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -88,11 +88,6 @@ setlocale(int category, const char *locale) size_t len; const char *env, *r; - if (issetugid() != 0 || - ((!_PathLocale && !(_PathLocale = getenv("PATH_LOCALE"))) || - !*_PathLocale)) - _PathLocale = _PATH_LOCALE; - if (category < 0 || category >= _LC_LAST) return (NULL); @@ -231,7 +226,7 @@ load_locale_sub(int category, const char *locname, int isspecial) return -1; len = snprintf(name, sizeof(name), "%s/%s/%s", - _PathLocale, locname, categories[category]); + _PATH_LOCALE, locname, categories[category]); if (len < 0 || len >= sizeof(name)) return -1; diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c index 8001b0087df..ff485551849 100644 --- a/lib/libc/locale/setrunelocale.c +++ b/lib/libc/locale/setrunelocale.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setrunelocale.c,v 1.5 2010/07/27 16:59:04 stsp Exp $ */ +/* $OpenBSD: setrunelocale.c,v 1.6 2011/03/15 22:27:48 stsp Exp $ */ /* $NetBSD: setrunelocale.c,v 1.14 2003/08/07 16:43:07 agc Exp $ */ /*- @@ -94,6 +94,7 @@ #include <assert.h> #include <errno.h> #include <limits.h> +#include <paths.h> #include <string.h> #include <stdio.h> #include <stdlib.h> @@ -183,7 +184,7 @@ _xpg4_setrunelocale(const char *encoding) } len = snprintf(path, sizeof(path), - "%s/%s/LC_CTYPE", _PathLocale, encoding); + "%s/%s/LC_CTYPE", _PATH_LOCALE, encoding); if (len < 0 || len >= sizeof(path)) return ENAMETOOLONG; |