diff options
| author | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-21 13:09:26 +0000 |
|---|---|---|
| committer | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-21 13:09:26 +0000 |
| commit | 298ff0cf4d0378eff4fe7f48ee088d6b389d49af (patch) | |
| tree | f49517adf454eb190e4f561679b72d618da9476a /ext | |
| parent | 977b19107d291a457e5909d1eb3cf6cfb8bb2e55 (diff) | |
| download | ruby-298ff0cf4d0378eff4fe7f48ee088d6b389d49af.tar.gz ruby-298ff0cf4d0378eff4fe7f48ee088d6b389d49af.tar.xz ruby-298ff0cf4d0378eff4fe7f48ee088d6b389d49af.zip | |
* ext/openssl/ossl_asn1.c (ossl_asn1_decode_all): use rb_str_new4
to avoid SEGV.
* ext/openssl/ossl_asn1.c (ossl_asn1_traverse, ossl_asn1_decode,
ossl_asn1_decode_all): temporary value should be marked volatile.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/openssl/ossl_asn1.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c index f353ce9b7..1ce5fa50c 100644 --- a/ext/openssl/ossl_asn1.c +++ b/ext/openssl/ossl_asn1.c @@ -813,11 +813,12 @@ ossl_asn1_traverse(VALUE self, VALUE obj) { unsigned char *p; long offset = 0; + volatile VALUE tmp; obj = ossl_to_der_if_possible(obj); - obj = rb_str_new4(StringValue(obj)); - p = RSTRING(obj)->ptr; - ossl_asn1_decode0(&p, RSTRING(obj)->len, &offset, 0, 0, 1); + tmp = rb_str_new4(StringValue(obj)); + p = RSTRING(tmp)->ptr; + ossl_asn1_decode0(&p, RSTRING(tmp)->len, &offset, 0, 0, 1); return Qnil; } @@ -828,11 +829,12 @@ ossl_asn1_decode(VALUE self, VALUE obj) VALUE ret, ary; unsigned char *p; long offset = 0; + volatile VALUE tmp; obj = ossl_to_der_if_possible(obj); - obj = rb_str_new4(StringValue(obj)); - p = RSTRING(obj)->ptr; - ary = ossl_asn1_decode0(&p, RSTRING(obj)->len, &offset, 0, 1, 0); + tmp = rb_str_new4(StringValue(obj)); + p = RSTRING(tmp)->ptr; + ary = ossl_asn1_decode0(&p, RSTRING(tmp)->len, &offset, 0, 1, 0); ret = rb_ary_entry(ary, 0); return ret; @@ -844,11 +846,12 @@ ossl_asn1_decode_all(VALUE self, VALUE obj) VALUE ret; unsigned char *p; long offset = 0; + volatile VALUE tmp; obj = ossl_to_der_if_possible(obj); - StringValue(obj); - p = RSTRING(obj)->ptr; - ret = ossl_asn1_decode0(&p, RSTRING(obj)->len, &offset, 0, 0, 0); + tmp = rb_str_new4(StringValue(obj)); + p = RSTRING(tmp)->ptr; + ret = ossl_asn1_decode0(&p, RSTRING(tmp)->len, &offset, 0, 0, 0); return ret; } |
