From d92d9a2661d62faf4a95a400109fd0c9f0ece256 Mon Sep 17 00:00:00 2001 From: usa Date: Thu, 20 Dec 2012 09:38:11 +0000 Subject: merge revision(s) 37572,37622,37766,37773: [Backport #7527] * string.c (rb_str_crypt): crypt(3) may return NULL. Latest glibc (2.16?) crypt(3) actually returns NULL. [Bug #7312] * test/ruby/test_m17n_comb.rb (test_str_crypt): Use RbConfig to get libc's directory. Patched by Vit Ondruch [ruby-core:49763] [Bug #7312] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@38503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'string.c') diff --git a/string.c b/string.c index 572a22a5fe..6ade42074a 100644 --- a/string.c +++ b/string.c @@ -6775,6 +6775,7 @@ rb_str_crypt(VALUE str, VALUE salt) extern char *crypt(const char *, const char *); VALUE result; const char *s, *saltp; + char *res; #ifdef BROKEN_CRYPT char salt_8bit_clean[3]; #endif @@ -6794,7 +6795,11 @@ rb_str_crypt(VALUE str, VALUE salt) saltp = salt_8bit_clean; } #endif - result = rb_str_new2(crypt(s, saltp)); + res = crypt(s, saltp); + if (!res) { + rb_sys_fail("crypt"); + } + result = rb_str_new2(res); OBJ_INFECT(result, str); OBJ_INFECT(result, salt); return result; -- cgit v1.2.3