diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-01 00:48:08 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-01 00:48:08 +0000 |
commit | 6657147ef22df5980928539a47634a6ba00cf006 (patch) | |
tree | 7ed2f1cac37397add7c7629a343f9fe8eecdb653 /string.c | |
parent | b82c3033fb0fcad57ff5abd74e29dbf9e77c2121 (diff) | |
download | ruby-6657147ef22df5980928539a47634a6ba00cf006.tar.gz |
use crypt_r
* string.c (rb_str_crypt): use reentrant crypt_r.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 18 |
1 files changed, 5 insertions, 13 deletions
@@ -29,6 +29,8 @@ #include <unistd.h> #endif +#include <crypt.h> + #define STRING_ENUMERATORS_WANTARRAY 0 /* next major */ #undef rb_str_new @@ -8373,13 +8375,10 @@ rb_str_oct(VALUE str) static VALUE rb_str_crypt(VALUE str, VALUE salt) { - extern char *crypt(const char *, const char *); + struct crypt_data data; VALUE result; const char *s, *saltp; char *res; -#ifdef BROKEN_CRYPT - char salt_8bit_clean[3]; -#endif StringValue(salt); mustnot_wchar(str); @@ -8392,15 +8391,8 @@ rb_str_crypt(VALUE str, VALUE salt) s = StringValueCStr(str); saltp = RSTRING_PTR(salt); if (!saltp[0] || !saltp[1]) goto short_salt; -#ifdef BROKEN_CRYPT - if (!ISASCII((unsigned char)saltp[0]) || !ISASCII((unsigned char)saltp[1])) { - salt_8bit_clean[0] = saltp[0] & 0x7f; - salt_8bit_clean[1] = saltp[1] & 0x7f; - salt_8bit_clean[2] = '\0'; - saltp = salt_8bit_clean; - } -#endif - res = crypt(s, saltp); + data.initialized = 0; + res = crypt_r(s, saltp, &data); if (!res) { rb_sys_fail("crypt"); } |