diff options
author | wollman <wollman@FreeBSD.org> | 1996-10-09 17:39:37 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1996-10-09 17:39:37 +0000 |
commit | 3d953050fb2396c16164170de0f2f546c1db5154 (patch) | |
tree | b81206bfc6349a8c2e3103482d16f16cf74405cb /lib | |
parent | 05c321a078d6834d7f31b6405f597228546b67f3 (diff) | |
download | FreeBSD-src-3d953050fb2396c16164170de0f2f546c1db5154.zip FreeBSD-src-3d953050fb2396c16164170de0f2f546c1db5154.tar.gz |
Require that a timezone specified via the TZ envariable be a regular
file (and not a directory or a device which might also be readable).
Closes PR#1740.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/stdtime/localtime.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c index ae302ec..5774354 100644 --- a/lib/libc/stdtime/localtime.c +++ b/lib/libc/stdtime/localtime.c @@ -17,6 +17,9 @@ static char elsieid[] = "@(#)localtime.c 7.57"; /*LINTLIBRARY*/ +#include <sys/types.h> +#include <sys/stat.h> + #include "private.h" #include "tzfile.h" #include "fcntl.h" @@ -274,10 +277,11 @@ register struct state * const sp; return -1; { register int doaccess; + struct stat stab; /* ** Section 4.9.1 of the C standard says that ** "FILENAME_MAX expands to an integral constant expression - ** that is the sie needed for an array of char large enough + ** that is the size needed for an array of char large enough ** to hold the longest file name string that the implementation ** guarantees can be opened." */ @@ -305,6 +309,8 @@ register struct state * const sp; return -1; if ((fid = open(name, OPEN_MODE)) == -1) return -1; + if ((fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode)) + return -1; } { struct tzhead * tzhp; |