From: daurnimator Date: Sun, 24 Nov 2013 09:35:44 +0000 (-0500) Subject: luatz/tzfile: Open files in readonly binary mode; and if invalid: throw a better... X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/92345b0a01c6c0142d2e3582275cd582743a729b?ds=inline;hp=66d1ace8410db940b6d1c74986626557ef8098ba luatz/tzfile: Open files in readonly binary mode; and if invalid: throw a better error message --- 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