From 92345b0a01c6c0142d2e3582275cd582743a729b Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 24 Nov 2013 04:35:44 -0500 Subject: [PATCH] luatz/tzfile: Open files in readonly binary mode; and if invalid: throw a better error message --- luatz/tzfile.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/luatz/tzfile.lua b/luatz/tzfile.lua index eed426e..96686dc 100644 --- a/luatz/tzfile.lua +++ b/luatz/tzfile.lua @@ -39,7 +39,7 @@ end local fifteen_nulls = ("\0"):rep(15) local function read_tz ( fd ) - assert ( fd:read(4) == "TZif" ) + assert ( fd:read(4) == "TZif" , "Invalid TZ file" ) local version = assert ( fd:read(1) ) if version == "\0" or version == "2" then local MIN_TIME = -2^32+1 @@ -198,7 +198,7 @@ local function read_tz ( fd ) end local function read_tzfile ( path ) - local fd = assert ( io.open ( path ) ) + local fd = assert ( io.open ( path , "rb" ) ) local tzinfo = read_tz ( fd ) fd:close ( ) return tzinfo -- 2.39.5