summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdtime/localtime.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdtime/localtime.c')
-rw-r--r--lib/libc/stdtime/localtime.c8
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;
OpenPOWER on IntegriCloud