ruby-changes:34965
From: nobu <ko1@a...>
Date: Mon, 4 Aug 2014 00:19:32 +0900 (JST)
Subject: [ruby-changes:34965] nobu:r47047 (trunk): ossl_pkcs7.c: consider length
nobu 2014-08-04 00:19:16 +0900 (Mon, 04 Aug 2014) New Revision: 47047 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47047 Log: ossl_pkcs7.c: consider length * ext/openssl/ossl_pkcs7.c (ossl_pkcs7_sym2typeid): consider length to compare. Modified files: trunk/ext/openssl/ossl_pkcs7.c Index: ext/openssl/ossl_pkcs7.c =================================================================== --- ext/openssl/ossl_pkcs7.c (revision 47046) +++ ext/openssl/ossl_pkcs7.c (revision 47047) @@ -362,6 +362,7 @@ ossl_pkcs7_sym2typeid(VALUE sym) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_pkcs7.c#L362 { int i, ret = Qnil; const char *s; + size_t l; static struct { const char *name; @@ -376,14 +377,13 @@ ossl_pkcs7_sym2typeid(VALUE sym) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_pkcs7.c#L377 { 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; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/