Skip to content

Commit

Permalink
Revert allowing non-literal bitstype immutables
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mbauman committed Jan 7, 2015
1 parent 33d9991 commit 5c7db4d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
2 changes: 1 addition & 1 deletion src/JLD.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}()
Expand Down
3 changes: 0 additions & 3 deletions test/jld.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 5c7db4d

Please sign in to comment.