aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_asn1.c
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-09-08 21:43:23 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-09-22 19:33:24 +0900
commite24b39f376e95530ac08bbab8301873f035b487d (patch)
tree6bdbf2e6764f96ba4d80646986132c70c7095e5f /ext/openssl/ossl_asn1.c
parentd23cbd4bc331f8bc0cd8c5e42eb3f5b027410b34 (diff)
downloadruby-openssl-e24b39f376e95530ac08bbab8301873f035b487d.tar.gz
asn1: fix error path in ossl_asn1_default_tag()
rb_class_superclass() returns nil when there is no available super class for the class object. Since the condition of the while statement is incorrect, we call rb_class_superclass() against nil. This fixes the segfault occurs with a code: OpenSSL::ASN1::Primitive.new("abc")
Diffstat (limited to 'ext/openssl/ossl_asn1.c')
-rw-r--r--ext/openssl/ossl_asn1.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index 4f9302e4..c4202946 100644
--- a/ext/openssl/ossl_asn1.c
+++ b/ext/openssl/ossl_asn1.c
@@ -631,17 +631,14 @@ ossl_asn1_default_tag(VALUE obj)
VALUE tmp_class, tag;
tmp_class = CLASS_OF(obj);
- while (tmp_class) {
+ while (!NIL_P(tmp_class)) {
tag = rb_hash_lookup(class_tag_map, tmp_class);
- if (tag != Qnil) {
- return NUM2INT(tag);
- }
- tmp_class = rb_class_superclass(tmp_class);
+ if (tag != Qnil)
+ return NUM2INT(tag);
+ tmp_class = rb_class_superclass(tmp_class);
}
ossl_raise(eASN1Error, "universal tag for %"PRIsVALUE" not found",
rb_obj_class(obj));
-
- return -1; /* dummy */
}
static int