[ruby/openssl] make config frozen on initialize
https://github.com/ruby/openssl/commit/50599513cf
This commit is contained in:
parent
06fc13a15c
commit
2a006fe54b
@ -87,6 +87,7 @@ config_s_parse(VALUE klass, VALUE str)
|
|||||||
|
|
||||||
bio = ossl_obj2bio(&str);
|
bio = ossl_obj2bio(&str);
|
||||||
config_load_bio(conf, bio); /* Consumes BIO */
|
config_load_bio(conf, bio); /* Consumes BIO */
|
||||||
|
rb_obj_freeze(obj);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +145,7 @@ config_initialize(int argc, VALUE *argv, VALUE self)
|
|||||||
ossl_raise(eConfigError, "BIO_new_file");
|
ossl_raise(eConfigError, "BIO_new_file");
|
||||||
config_load_bio(conf, bio); /* Consumes BIO */
|
config_load_bio(conf, bio); /* Consumes BIO */
|
||||||
}
|
}
|
||||||
|
rb_obj_freeze(self);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,6 +160,7 @@ config_initialize_copy(VALUE self, VALUE other)
|
|||||||
rb_check_frozen(self);
|
rb_check_frozen(self);
|
||||||
bio = ossl_obj2bio(&str);
|
bio = ossl_obj2bio(&str);
|
||||||
config_load_bio(conf, bio); /* Consumes BIO */
|
config_load_bio(conf, bio); /* Consumes BIO */
|
||||||
|
rb_obj_freeze(self);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ __EOD__
|
|||||||
assert_equal("[ default ]\n\n", c.to_s)
|
assert_equal("[ default ]\n\n", c.to_s)
|
||||||
c = OpenSSL::Config.parse(@it.to_s)
|
c = OpenSSL::Config.parse(@it.to_s)
|
||||||
assert_equal(['CA_default', 'ca', 'default'], c.sections.sort)
|
assert_equal(['CA_default', 'ca', 'default'], c.sections.sort)
|
||||||
|
assert_predicate(c, :frozen?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_s_parse_format
|
def test_s_parse_format
|
||||||
@ -188,6 +189,7 @@ __EOC__
|
|||||||
c = OpenSSL::Config.new
|
c = OpenSSL::Config.new
|
||||||
assert_equal("", c.to_s)
|
assert_equal("", c.to_s)
|
||||||
assert_equal([], c.sections)
|
assert_equal([], c.sections)
|
||||||
|
assert_predicate(c, :frozen?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_initialize_with_empty_file
|
def test_initialize_with_empty_file
|
||||||
@ -268,8 +270,10 @@ __EOC__
|
|||||||
def test_dup
|
def test_dup
|
||||||
assert_equal(['CA_default', 'ca', 'default'], @it.sections.sort)
|
assert_equal(['CA_default', 'ca', 'default'], @it.sections.sort)
|
||||||
c1 = @it.dup
|
c1 = @it.dup
|
||||||
|
assert_predicate(c1, :frozen?)
|
||||||
assert_equal(@it.sections.sort, c1.sections.sort)
|
assert_equal(@it.sections.sort, c1.sections.sort)
|
||||||
c2 = @it.clone
|
c2 = @it.clone
|
||||||
|
assert_predicate(c2, :frozen?)
|
||||||
assert_equal(@it.sections.sort, c2.sections.sort)
|
assert_equal(@it.sections.sort, c2.sections.sort)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user