diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-03 15:19:16 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-03 15:19:16 +0000 |
commit | 98630412982590136fe7d252b5697020aa255dbd (patch) | |
tree | ba91090bd276a4cd73f9f7fbf76990ec933b0bda /ext/openssl/ossl_pkcs7.c | |
parent | a98c65338d098aa9ababe99bebb05e174e281d53 (diff) |
ossl_pkcs7.c: consider length
* ext/openssl/ossl_pkcs7.c (ossl_pkcs7_sym2typeid): consider
length to compare.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_pkcs7.c')
-rw-r--r-- | ext/openssl/ossl_pkcs7.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/openssl/ossl_pkcs7.c b/ext/openssl/ossl_pkcs7.c index 8b1a51903c..23de7dd558 100644 --- a/ext/openssl/ossl_pkcs7.c +++ b/ext/openssl/ossl_pkcs7.c @@ -362,6 +362,7 @@ ossl_pkcs7_sym2typeid(VALUE sym) { int i, ret = Qnil; const char *s; + size_t l; static struct { const char *name; @@ -376,14 +377,13 @@ ossl_pkcs7_sym2typeid(VALUE sym) { NULL, 0 }, }; - if (RB_TYPE_P(sym, T_SYMBOL)) { - sym = rb_sym2str(sym); - s = RSTRING_PTR(sym); - } - else s = StringValuePtr(sym); + if (RB_TYPE_P(sym, T_SYMBOL)) sym = rb_sym2str(sym); + else StringValue(sym); + RSTRING_GETMEM(sym, s, l); for(i = 0; i < numberof(p7_type_tab); i++){ if(p7_type_tab[i].name == NULL) ossl_raise(ePKCS7Error, "unknown type \"%s\"", s); + if(strlen(p7_type_tab[i].name) != l) continue; if(strcmp(p7_type_tab[i].name, s) == 0){ ret = p7_type_tab[i].nid; break; |