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.
This commit is contained in:
wollman 1996-10-09 17:39:37 +00:00
parent f333bc0b88
commit 418fcb9d82

View File

@ -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;