From 5c7db4d9fbf48b884e2333e46a9798ac4e89d997 Mon Sep 17 00:00:00 2001 From: Matt Bauman Date: Wed, 7 Jan 2015 12:02:21 -0500 Subject: [PATCH] Revert allowing non-literal bitstype immutables As pointed out by @simonster, this ends up `eval`-ing any call written into the HDF5 file as a type parameter and is a security threat. --- src/JLD.jl | 2 +- test/jld.jl | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/JLD.jl b/src/JLD.jl index 3fd485e6d..0b1b45827 100644 --- a/src/JLD.jl +++ b/src/JLD.jl @@ -751,7 +751,7 @@ is_valid_type_ex(s::Symbol) = true is_valid_type_ex(s::QuoteNode) = true is_valid_type_ex{T}(::T) = isbits(T) is_valid_type_ex(e::Expr) = ((e.head == :curly || e.head == :tuple || e.head == :.) && all(map(is_valid_type_ex, e.args))) || - (e.head == :call && isa(e.args[1], Symbol)) + (e.head == :call && (e.args[1] == :Union || e.args[1] == :TypeVar)) # Work around https://github.com/JuliaLang/julia/issues/8226 const _typedict = Dict{String,Type}() diff --git a/test/jld.jl b/test/jld.jl index bb025fccb..0e5811585 100644 --- a/test/jld.jl +++ b/test/jld.jl @@ -191,7 +191,6 @@ Sbig = "A test string "^1000 type BitsParams{x}; end bitsparamfloat = BitsParams{1.0}() bitsparambool = BitsParams{true}() -bitsparamimmut = BitsParams{PaddingTest(1,2)}() bitsparamsymbol = BitsParams{:x}() iseq(x,y) = isequal(x,y) @@ -370,7 +369,6 @@ for compress in (true,false) @write fid Sbig @write fid bitsparamfloat @write fid bitsparambool - @write fid bitsparamimmut @write fid bitsparamsymbol # Make sure we can create groups (i.e., use HDF5 features) @@ -488,7 +486,6 @@ for compress in (true,false) @check fidr Sbig @check fidr bitsparamfloat @check fidr bitsparambool - @check fidr bitsparamimmut @check fidr bitsparamsymbol x1 = read(fidr, "group1/x")